Last active
July 31, 2019 09:47
-
-
Save noskill/cabe8f529b3474ae35747ac89be9081c to your computer and use it in GitHub Desktop.
alpha-equivalence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from opencog.utilities import initialize_opencog, tmp_atomspace | |
| from opencog.type_constructors import * | |
| from opencog.bindlink import execute_atom | |
| def test1(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| VariableNode("X0"), | |
| VariableNode("X1") | |
| ) | |
| imp2 = ImplicationLink( | |
| VariableNode("X3"), | |
| VariableNode("X5") | |
| ) | |
| bind = BindLink(imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| def test2(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| VariableNode("X0"), | |
| VariableNode("X1") | |
| ) | |
| imp2 = ImplicationLink( | |
| VariableNode("X1"), | |
| VariableNode("X5") | |
| ) | |
| varlist = VariableList(TypedVariableLink(VariableNode("X1"), TypeNode("VariableNode")), | |
| TypedVariableLink(VariableNode("X5"), TypeNode("VariableNode"))) | |
| bind = BindLink(varlist, imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| def test3(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| VariableNode("X0"), | |
| VariableNode("X1") | |
| ) | |
| imp2 = ImplicationLink( | |
| VariableNode("X1"), | |
| VariableNode("X5") | |
| ) | |
| bind = BindLink(imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| def test4(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| VariableNode("X0"), | |
| VariableNode("X1") | |
| ) | |
| imp2 = ImplicationLink( | |
| VariableNode("X1"), | |
| VariableNode("X5") | |
| ) | |
| varlist = [TypedVariableLink(VariableNode("X1"), TypeNode("VariableNode")), | |
| TypedVariableLink(VariableNode("X5"), TypeNode("VariableNode"))] | |
| bind = BindLink(varlist, imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| def test5(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| VariableNode("X0"), | |
| VariableNode("X1") | |
| ) | |
| imp2 = ImplicationLink( | |
| VariableNode("X1"), | |
| VariableNode("X5") | |
| ) | |
| varlist = VariableList() | |
| bind = BindLink(varlist, imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| def test6(): | |
| atomspace = AtomSpace() | |
| initialize_opencog(atomspace) | |
| imp1 = ImplicationLink( | |
| InheritanceLink(VariableNode("X5"), | |
| VariableNode("X1"), | |
| VariableNode("X3")), | |
| EvaluationLink( | |
| PredicateNode("P"), | |
| VariableNode("X1") | |
| ) | |
| ) | |
| imp2 = ImplicationLink( | |
| InheritanceLink(GlobNode("X0"), | |
| GlobNode("X1")), | |
| EvaluationLink( | |
| PredicateNode("P"), | |
| GlobNode("X1") | |
| ) | |
| ) | |
| bind = BindLink(imp2, imp2) | |
| print(execute_atom(atomspace, bind)) | |
| test1() | |
| test2() | |
| test3() | |
| test4() | |
| test5() | |
| test6() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(cog-execute! (GetLink (TypedVariable (VariableNode "T") (Signature (ImplicationLink (Type "VariableNode") (Type "VariableNode")))) (Variable "T")))