Advertisement
logicmoo

Untitled

Apr 27th, 2019
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 3.03 KB | None | 0 0
  1. % larkc_holds(Mt,here(X)) and generate clEval(['ASK-TEMPLATE',[quote,'?X'],[quote,[here,'?X']],[quote,Mt]]).
  2.  
  3. larkc_holds(Prolog):-
  4.   pengine_self(Session),
  5.   getMicrotheoryFromSessionID(Session,Mt),
  6.   larkc_holds(Mt,Prolog).
  7.  
  8. larkc_holds(Mt,Prolog):-
  9.   ISTPROLOG = ist(Mt,Prolog),
  10.   term_variables(Prolog,PrologVars),
  11.   into_cycl_form(ISTPROLOG,ISTFORM),
  12.   harden_cycl_vars(PrologVars+ISTFORM,CycLVars+ISTLISP),
  13.   ISTLISP = ['ist',HLMt,ELAsk],
  14.   cl_quote(Q),
  15.   clEval(['CYC:ASK-TEMPLATE',[Q,CycLVars],[Q,ELAsk],[Q,HLMt],ResultL),
  16.   member(Result,ResultL),
  17.   unify_cycl_form(PrologVars,Result).
  18.  
  19. cl_quote('CL:QUOTE'):-!.
  20. cl_quote('\'').  % '
  21.  
  22.  
  23. harden_cycl_vars(G,G):- ground(G),!.
  24. harden_cycl_vars(V,N):- var(V),var_property(V,name(VN)),!,atom_concat('?',VN,N).
  25. harden_cycl_vars(V,N):- var(V),!,format(atom(N),'?~w',[V]).
  26. harden_cycl_vars(G,G):- \+ compound(G),!.
  27. harden_cycl_vars(A,AA):- compound_name_arguments(A,F,AL),maplist(harden_cycl_vars,AL,AAL),compound_name_arguments(AA,F,AAL).
  28.  
  29. cycl_2:-fail.
  30.  
  31. into_cycl_form(A,AA):- var(A),!,A=AA.
  32. into_cycl_form(',','and'):- !.
  33. into_cycl_form(';','or'):- !.
  34. into_cycl_form(A,AA):- atomic(A),!,A=AA.
  35. into_cycl_form((A:-B),'sentenceImplies'(BB,AA)):- cycl_2, !, into_cycl_form(A,AA),into_cycl_form(B,BB).
  36. into_cycl_form((A:-B),'implies'(BB,AA)):- !, into_cycl_form(A,AA),into_cycl_form(B,BB).
  37. into_cycl_form(M:P,AA):- \+ atomic(P),!,into_cycl_form(ist(M,P),AA).
  38. into_cycl_form(A,AA):- A=..AL, maplist(into_cycl_form,AL,AA).
  39.  
  40.  
  41.  
  42. unify_cycl_form(Binding,Binding):- (var(Binding);number(Binding)),!.
  43. unify_cycl_form(string(B),string(B)):-!.
  44. unify_cycl_form(Binding,BindingP):-atom(Binding),atom_concat('#$',BindingP,Binding),!.
  45. unify_cycl_form(nart(B),nart(BB)):-unify_cycl_form(B,BB),!.
  46. unify_cycl_form(nart(B),(BB)):-!,unify_cycl_form(B,BB),!.
  47. %unify_cycl_form(string(B),List):-atomSplit(List,B),!.
  48. unify_cycl_form(string(B),B):-!.
  49. unify_cycl_form(string([]),""):-!.
  50. unify_cycl_form(quote(B),BO):-!,unify_cycl_form(B,BO).
  51. unify_cycl_form([A|L],Binding):-unify_cycl_formCons(A,L,Binding),!.
  52. unify_cycl_form(Binding,Binding):-!.
  53.  
  54. unify_cycl_formCons(A,L,[A|L]):- (var(A);var(L);A=string(_);number(A)),!.
  55. % unify_cycl_formCons('and-also',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  56. % unify_cycl_formCons('eval',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  57. % unify_cycl_formCons('#$and-also',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  58. unify_cycl_formCons(A,L,Binding):-
  59.      unify_cycl_form(A,AO),
  60.          unify_cycl_formCons(A,AO,L,Binding).
  61. unify_cycl_formCons(A,AO,L,Binding):-
  62.          atom(AO),!,
  63.      unify_cycl_formS(L,LO),
  64.      Binding=..[AO|LO],!.
  65. unify_cycl_formCons(A,AO,L,Binding):-
  66.      unify_cycl_formS(L,LO),
  67.      Binding=[AO|LO],!.
  68.  
  69. unify_cycl_formS(Binding,Binding):- (var(Binding);atom(Binding);number(Binding)),!.
  70. unify_cycl_formS([],[]).
  71. unify_cycl_formS([V,[L]|M],[LL|ML]):- nonvar(V), cl_quote(V),unify_cycl_formS(L,LL),unify_cycl_formS(M,ML).
  72. unify_cycl_formS([A|L],[AA|LL]):-unify_cycl_form(A,AA),unify_cycl_formS(L,LL).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement