@@ -610,20 +610,37 @@ def test_implicates_implicants_idempotent(sentence: nnf.NNF):
610610 assert implicates .implicants () == implicants
611611
612612
613- # TODO: This test fails, see the example below.
614- # I don't know if this is a bug in the test or in the implementation.
615- @pytest .mark .xfail
616613@given (NNF ())
617614def test_implicates_implicants_negation_rule (sentence : nnf .NNF ):
618- assert sentence .negate ().implicants ().negate () == sentence .implicates ()
619- assert sentence .negate ().implicates ().negate () == sentence .implicants ()
615+ """Any implicate is also a negated implicant of the negated sentence.
616+
617+ .implicates() gives some implicates, and .implicants() gives all
618+ implicants.
619+
620+ So sentence.negate().implicants().negate() gives all implicates,
621+ and sentence.negate().implicates().negate() gives some implicants.
622+ """
623+ assert (
624+ sentence .negate ().implicants ().negate ().children
625+ >= sentence .implicates ().children
626+ )
627+ assert (
628+ sentence .negate ().implicates ().negate ().children
629+ <= sentence .implicants ().children
630+ )
620631
621632
622- @pytest .mark .xfail (strict = True )
623633def test_implicates_implicants_negation_rule_example ():
634+ """These failed an old version of the previous test. See issue #3."""
624635 sentence = Or ({And ({~ Var (1 ), Var (2 )}), And ({~ Var (3 ), Var (1 )})})
625- assert sentence .negate ().implicants ().negate () == sentence .implicates ()
626- assert sentence .negate ().implicates ().negate () == sentence .implicants ()
636+ assert (
637+ sentence .negate ().implicants ().negate ().children
638+ >= sentence .implicates ().children
639+ )
640+ assert (
641+ sentence .negate ().implicates ().negate ().children
642+ <= sentence .implicants ().children
643+ )
627644
628645
629646@given (NNF (), NNF ())
0 commit comments