Skip to content

vinid/pymetheus

Repository files navigation

Pymetheus

Documentation Status

PyMetheus: Deep Nets for Logical Reasoning

Features

  • Provides an out of the box tool to learn (fuzz) first order logic with the use of an underlying vector space

Features

  • Create a Logic Deep Network
from pymetheus.pymetheus import LogicNet

ll = LogicNet()
  • Introduce Some Constants
ll.constant("A")
ll.constant("B")
ll.constant("C")
ll.constant("D")
ll.constant("E")
  • Introduce Some Predicates and Knowledge
ll.predicate("over")
ll.predicate("under")

ll.knowledge("over(A,B)")
ll.knowledge("over(B,C)")
ll.knowledge("over(C,D)")
  • Add quantified rule with data
variables = ["A", "B", "C", "D", "E"]
ll.variable("?a", variables)
ll.variable("?b", variables)
ll.variable("?c", variables)

rule = "forall ?a,?b: over(?a,?b) -> under(?b,?a)"
rule_2 = "forall ?a,?b: under(?a,?b) -> over(?b,?a)"

rule_3 = "forall ?a,?b,?c: (over(?a,?b) & over(?b,?c)) -> over(?a,?c)"

rule_4 = "forall ?a,?b,?c: (under(?a,?b) & under(?b,?c)) -> under(?a,?c)"

rule_5 = "forall ?a,?b: over(?a,?b) -> ~over(?b,?a)"
rule_6 = "forall ?a,?b: under(?a,?b) -> ~under(?b,?a)"

ll.universal_rule(rule)
ll.universal_rule(rule_2)
ll.universal_rule(rule_3)
ll.universal_rule(rule_4)
ll.universal_rule(rule_6)
  • Learn and Reason
ll.fit(epochs=2000, grouping=99)


ll.reason("over(A,D)", True)
ll.reason("over(D,A)", True)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published