Example #1
0
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}
Example #2
0
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}
Example #3
0
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}
Example #4
0
 def D(facts):
     kb = FactKB(f)
     kb.deduce_all_facts(facts)
     return kb
Example #5
0
 def D(facts):
     kb = FactKB(f)
     kb.deduce_all_facts(facts)
     return kb