Exemple #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}
Exemple #2
0
        def __new__(cls, name, **kwargs):
            if not isinstance(name, six.string_types):
                raise TypeError("name should be a string, not %s" % repr(type(name)))

            obj = sympy.Symbol.__new__(cls, str(uuid.uuid1()))

            obj.name = name
            obj._assumptions = FactKB(_assume_rules)
            obj._assumptions._tell('commutative', True)
            obj._assumptions._tell('uuid', uuid.uuid1())

            return obj
Exemple #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}
Exemple #4
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}
Exemple #5
0
 def D(facts):
     kb = FactKB(f)
     kb.deduce_all_facts(facts)
     return kb
Exemple #6
0
 def D(facts):
     kb = FactKB(f)
     kb.deduce_all_facts(facts)
     return kb