Example #1
0
        public static void MyPlaygroundForL1Expressions()
        {
            var rules = new RuleSet();
            var p = rules.Define1("p");
            var q = rules.Define1("q");

            // Axioms
//            rules += x => p(x) | q(x) | !p("c");
            rules += x => p(x) | q(x);
            rules += x => !p(x) | q(x);
            rules += x => p(x) | !q(x);

            // Conclusion
            rules.Prove(p("c") & q("c"));
        }
Example #2
0
        public static void OldMainExample()
        {
            var rules = new RuleSet();

            var isType = rules.Define1("is a type");
            var extends = rules.Define2("extends");
            var isPof = rules.Define2("is parent of");

            // Axioms
            rules += (X, Y) => (extends(Y, X) & isType(X) & isType(Y)) > isPof(X, Y);

            // Factum
            rules += isType("C1");
            rules += isType("C2");
            rules += extends("C1", "C2");

            // Conclusion
            rules.Prove(isPof("C2", "C1")); // should be true
        }
Example #3
0
        public static void ExtendsBelongs()
        {
            var rules = new RuleSet();

            var isType = rules.Define1("is a type");
            var extends = rules.Define2("extends");
            var belongs = rules.Define2("belongs");

            // Axioms
            rules += (X, Y, P) => (extends(Y, X) & isType(X) & isType(Y) & belongs(P, X)) > belongs(P, Y);

            // Factum
            rules += isType("C1");
            rules += isType("C2");
            rules += extends("C1", "C2");
            rules += belongs("P1", "C2");

            // Conclusion
            rules.Prove(belongs("P1", "C1"));
        }
Example #4
0
        public static void AdContrary()
        {
            var rules = new RuleSet();
            var p = rules.Define1("p");
            var q = rules.Define1("q");

            // Axioms
            rules += x => p(x) > q(x);

            // Factum
            rules += !q("c");

            // Conclusion
            rules.Prove(!p("c"));
//            rules.Prove(!p("c") | q("c"));
        }
Example #5
0
        public static void ExampleOfHighlyInefficientResolution()
        {
            var rules = new RuleSet();
            var p = rules.Define1("p");
            var q = rules.Define1("q");

            // Axioms
            rules += x => p(x) | q(x);
            rules += x => !p(x) | q(x);
            rules += x => p(x) | !q(x);

            // Conclusion
            rules.Prove(p("c") & q("c"));
        }
Example #6
0
        public static void SyntaxDemo()
        {
            var rules = new RuleSet();

            var isType = rules.Define1("is a type");
            var extends = rules.Define2("extends");
            var isPof = rules.Define2("is parent of");

            // Axioms
            rules += (X, Y) => (extends(Y, X) & isType(X) & isType(Y)) > isPof(X, Y);

            // Factum
            rules += isType("C1");
            rules += isType("C2");
            rules += extends("C1", "C2");

            // Conclusion
            rules.Prove(isPof("C2", "C1")); // should be true

            // Extensions (to demonstrate additional capabilites)
            var toString = (!isType("dog") & isType("Object")).ToString();
            rules += !isType("dog") & isType("Object");
            // TODO. definition is incomplete, since no function calls are allowed in predicates
            var equals = rules.Define2("equals");
            rules += x => isType(x) > (extends(x, "Object") | equals(x, "Object"));
        }