Exemplo n.º 1
0
 /// <summary>
 /// This is a simplified findall when the goal is a single call.
 /// </summary>
 /// <param name="Template"></param>
 /// <param name="goal"></param>
 /// <param name="Bag"></param>
 /// <returns></returns>
 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
 {
     FindallAnswers findallAnswers = new FindallAnswers(Template);
     foreach (bool l1 in goal)
         findallAnswers.add();
     return findallAnswers.result(Bag);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Like findall, except return an array of the results.
        /// </summary>
        /// <param name="template"></param>
        /// <param name="goal"></param>
        /// <returns></returns>
        public static List <object> findallArray(object Template, IEnumerable <bool> goal)
        {
            FindallAnswers findallAnswers = new FindallAnswers(Template);

            foreach (bool l1 in goal)
            {
                findallAnswers.add();
            }
            return(findallAnswers.resultArray());
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is a simplified findall when the goal is a single call.
        /// </summary>
        /// <param name="Template"></param>
        /// <param name="goal"></param>
        /// <param name="Bag"></param>
        /// <returns></returns>
        public static IEnumerable <bool> findall(object Template, IEnumerable <bool> goal, object Bag)
        {
            FindallAnswers findallAnswers = new FindallAnswers(Template);

            foreach (bool l1 in goal)
            {
                findallAnswers.add();
            }
            return(findallAnswers.result(Bag));
        }
Exemplo n.º 4
0
 public static IEnumerable<bool> run_all_tests()
 {
     {
         Variable F = new Variable();
         Variable Files = new Variable();
         FindallAnswers findallAnswers1 = new FindallAnswers(F);
         foreach (bool l2 in file(F))
         {
             findallAnswers1.add();
         }
         foreach (bool l2 in findallAnswers1.result(Files))
         {
             foreach (bool l3 in test_all(Files))
             {
                 foreach (bool l4 in write_results())
                 {
                     yield return true;
                     yield break;
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 public static IEnumerable<bool> write_results()
 {
     {
         Variable F = new Variable();
         Variable ErrorBips = new Variable();
         FindallAnswers findallAnswers1 = new FindallAnswers(F);
         foreach (bool l2 in inerror(F))
         {
             findallAnswers1.add();
         }
         foreach (bool l2 in findallAnswers1.result(ErrorBips))
         {
             YP.write(Atom.a("--------------------"));
             YP.nl();
             foreach (bool l3 in YP.unify(ErrorBips, Atom.NIL))
             {
                 YP.write(Atom.a("All bips passed -------------"));
                 YP.nl();
                 yield return false;
                 goto cutIf2;
             }
             YP.nl();
             YP.write(Atom.a("The following BIPs gave unexpected answers:"));
             YP.nl();
             YP.write(Atom.a("The results should be examined carefully."));
             YP.nl();
             YP.nl();
             foreach (bool l3 in display_list(ErrorBips))
             {
                 yield return false;
             }
         cutIf2:
             { }
         }
     }
 }
Exemplo n.º 6
0
 public static IEnumerable<bool> compileSamePredicateFunction(object SamePredicateRuleList, object State, object FunctionCode)
 {
     {
         Variable FirstRule = new Variable();
         Variable x5 = new Variable();
         Variable x6 = new Variable();
         Variable x7 = new Variable();
         Variable Head = new Variable();
         Variable x9 = new Variable();
         Variable ArgAssignments = new Variable();
         Variable Calls = new Variable();
         Variable Rule = new Variable();
         Variable VariableNameSuggestions = new Variable();
         Variable ClauseBag = new Variable();
         Variable Name = new Variable();
         Variable ArgsList = new Variable();
         Variable FunctionArgNames = new Variable();
         Variable MergedArgName = new Variable();
         Variable ArgName = new Variable();
         Variable MergedArgNames = new Variable();
         Variable FunctionArgs = new Variable();
         Variable BodyCode = new Variable();
         Variable ReturnType = new Variable();
         Variable BodyWithReturn = new Variable();
         foreach (bool l2 in YP.unify(new ListPair(new Functor2("f", FirstRule, x5), x6), SamePredicateRuleList))
         {
             foreach (bool l3 in YP.unify(FirstRule, new Functor1(":-", x7)))
             {
                 goto cutIf1;
             }
             foreach (bool l3 in YP.unify(new Functor2(":-", Head, x9), FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers3 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers3.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers3.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers4 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers4.add();
                                     goto cutIf5;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers4.add();
                                 }
                             cutIf5:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers4.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf7;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf8;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf9;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf9:
                                             cutIf8:
                                             cutIf7:
                                                 { }
                                             }
                                             goto cutIf6;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf11;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf12;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf13;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf13:
                                             cutIf12:
                                             cutIf11:
                                                 { }
                                             }
                                             goto cutIf10;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf14;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf15;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf16;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf16:
                                         cutIf15:
                                         cutIf14:
                                             { }
                                         }
                                     cutIf10:
                                     cutIf6:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 goto cutIf2;
             }
             foreach (bool l3 in YP.unify(Head, FirstRule))
             {
                 CompilerState.startFunction(State, Head);
                 FindallAnswers findallAnswers17 = new FindallAnswers(new Functor2("f", ArgAssignments, Calls));
                 foreach (bool l4 in member(new Functor2("f", Rule, VariableNameSuggestions), SamePredicateRuleList))
                 {
                     foreach (bool l5 in compileBodyWithHeadBindings(Rule, VariableNameSuggestions, State, ArgAssignments, Calls))
                     {
                         findallAnswers17.add();
                     }
                 }
                 foreach (bool l4 in findallAnswers17.result(ClauseBag))
                 {
                     foreach (bool l5 in YP.univ(Head, new ListPair(Name, ArgsList)))
                     {
                         foreach (bool l6 in getFunctionArgNames(ArgsList, 1, FunctionArgNames))
                         {
                             FindallAnswers findallAnswers18 = new FindallAnswers(MergedArgName);
                             foreach (bool l7 in member(ArgName, FunctionArgNames))
                             {
                                 foreach (bool l8 in argAssignedAll(ArgName, ClauseBag, MergedArgName))
                                 {
                                     findallAnswers18.add();
                                     goto cutIf19;
                                 }
                                 foreach (bool l8 in YP.unify(MergedArgName, ArgName))
                                 {
                                     findallAnswers18.add();
                                 }
                             cutIf19:
                                 { }
                             }
                             foreach (bool l7 in findallAnswers18.result(MergedArgNames))
                             {
                                 foreach (bool l8 in maplist_arg(MergedArgNames, FunctionArgs))
                                 {
                                     foreach (bool l9 in maplist_compileClause(ClauseBag, MergedArgNames, BodyCode))
                                     {
                                         if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("void")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf21;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf22;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf23;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf23:
                                             cutIf22:
                                             cutIf21:
                                                 { }
                                             }
                                             goto cutIf20;
                                         }
                                         if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                         {
                                             foreach (bool l11 in YP.unify(ReturnType, Atom.a("bool")))
                                             {
                                                 if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                                 {
                                                     foreach (bool l13 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf25;
                                                 }
                                                 if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf26;
                                                 }
                                                 if (CompilerState.codeUsesYield(State))
                                                 {
                                                     foreach (bool l13 in YP.unify(BodyWithReturn, BodyCode))
                                                     {
                                                         foreach (bool l14 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                         {
                                                             yield return false;
                                                         }
                                                     }
                                                     goto cutIf27;
                                                 }
                                                 foreach (bool l12 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                             cutIf27:
                                             cutIf26:
                                             cutIf25:
                                                 { }
                                             }
                                             goto cutIf24;
                                         }
                                         foreach (bool l10 in YP.unify(ReturnType, Atom.a("IEnumerable<bool>")))
                                         {
                                             if (CompilerState.determinismEquals(State, Atom.a("semidetNoneOut")))
                                             {
                                                 foreach (bool l12 in append(BodyCode, new ListPair(Atom.a("returnfalse"), Atom.NIL), BodyWithReturn))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf28;
                                             }
                                             if (CompilerState.determinismEquals(State, Atom.a("detNoneOut")))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf29;
                                             }
                                             if (CompilerState.codeUsesYield(State))
                                             {
                                                 foreach (bool l12 in YP.unify(BodyWithReturn, BodyCode))
                                                 {
                                                     foreach (bool l13 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                     {
                                                         yield return false;
                                                     }
                                                 }
                                                 goto cutIf30;
                                             }
                                             foreach (bool l11 in append(BodyCode, new ListPair(new Functor1("blockScope", new ListPair(new Functor2("foreach", new Functor2("call", Atom.a("YP.fail"), Atom.NIL), new ListPair(Atom.a("yieldfalse"), Atom.NIL)), Atom.NIL)), Atom.NIL), BodyWithReturn))
                                             {
                                                 foreach (bool l12 in YP.unify(FunctionCode, new Functor("function", new object[] { ReturnType, Name, FunctionArgs, BodyWithReturn })))
                                                 {
                                                     yield return false;
                                                 }
                                             }
                                         cutIf30:
                                         cutIf29:
                                         cutIf28:
                                             { }
                                         }
                                     cutIf24:
                                     cutIf20:
                                         { }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         cutIf2:
         cutIf1:
             { }
         }
     }
 }
Exemplo n.º 7
0
 public static IEnumerable<bool> get_all_subs(object G, object AllSubs)
 {
     {
         Variable GT = new Variable();
         Variable GVars = new Variable();
         Variable GTAns = new Variable();
         Variable GTAnsList = new Variable();
         foreach (bool l2 in YP.copy_term(G, GT))
         {
             foreach (bool l3 in vars_in_term(G, GVars))
             {
                 FindallAnswers findallAnswers1 = new FindallAnswers(GTAns);
                 foreach (bool l4 in protect_call_result(GT, GTAns))
                 {
                     findallAnswers1.add();
                 }
                 foreach (bool l4 in findallAnswers1.result(GTAnsList))
                 {
                     foreach (bool l5 in list_make_subs_list(GVars, GTAnsList, AllSubs))
                     {
                         yield return false;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Like findall, except return an array of the results.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="goal"></param>
 /// <returns></returns>
 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
 {
     FindallAnswers findallAnswers = new FindallAnswers(Template);
     foreach (bool l1 in goal)
         findallAnswers.add();
     return findallAnswers.resultArray();
 }
Exemplo n.º 9
0
 public static IEnumerable<bool> parseInput(object TermList)
 {
     {
         Variable TermAndVariables = new Variable();
         FindallAnswers findallAnswers1 = new FindallAnswers(TermAndVariables);
         foreach (bool l2 in parseInputHelper(TermAndVariables))
         {
             findallAnswers1.add();
         }
         foreach (bool l2 in findallAnswers1.result(TermList))
         {
             yield return false;
         }
     }
 }