def test_inconsistent_assumptions(): kb = FactKB(FactRules(['npos -> ~pos', 'pos -> ~npos'])) with pytest.raises(InconsistentAssumptions) as err: kb.deduce_all_facts({'pos': T, 'npos': T}) assert str(err.value) in [ '{\n\tnpos: False,\n\tpos: True}, npos=True', '{\n\tnpos: True,\n\tpos: False}, pos=True' ]
def test_FactRules_deduce_base(): # deduction that starts from base f = FactRules(['real == neg | zero | pos', 'neg -> real & ~zero & ~pos', 'pos -> real & ~zero & ~neg']) base = FactKB(f) base.deduce_all_facts({'real': T, 'neg': F}) assert base == {'real': T, 'neg': F} base.deduce_all_facts({'zero': F}) assert base == {'real': T, 'neg': F, 'zero': F, 'pos': T}
def D(facts): kb = FactKB(f) kb.deduce_all_facts(facts) return kb
def test_inconsistent_assumptions(): kb = FactKB(FactRules(['npos -> ~pos', 'pos -> ~npos'])) with pytest.raises(InconsistentAssumptions) as err: kb.deduce_all_facts({'pos': T, 'npos': T}) assert str(err.value) in ['{\n\tnpos: False,\n\tpos: True}, npos=True', '{\n\tnpos: True,\n\tpos: False}, pos=True']