Advertisement
logicmoo

Untitled

Apr 27th, 2019
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 2.99 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.   into_cycl_form(ISTPROLOG,ISTFORM),
  11.   harden_cycl_vars(ISTFORM,ISTLISP),
  12.   assertion(ISTFORM = ['ist',_HLMt,_ELAsk]),
  13.   cl_quote(Q),
  14.   clEval(['CYC:ASK-TEMPLATE',[Q,ISTLISP],[Q,ISTLISP],'EverythingPSC'],Result),
  15.   member(Result,ResultL),
  16.   unify_cycl_form(ISTFORM,ISTFORM).
  17.  
  18. cl_quote('CL:QUOTE').
  19. cl_quote('\'').  % '
  20.  
  21.  
  22. harden_cycl_vars(G,G):- ground(G),!.
  23. harden_cycl_vars(V,N):- var(V),!,var_property(V,name(VN)),!,atom_concat('?',VN,N).
  24. harden_cycl_vars(V,N):- var(V),!,format(atom(N),'?~w',[V]).
  25. harden_cycl_vars(G,G):- \+ compound(G),!.
  26. harden_cycl_vars(A,AA):- compound_name_arguments(A,F,AL),maplist(harden_cycl_vars,AL,AAL),compound_name_arguments(AA,F,AAL).
  27.  
  28. cycl_2:-fail.
  29.  
  30. into_cycl_form(A,AA):- var(A),!,A=AA.
  31. into_cycl_form(',','and'):- !.
  32. into_cycl_form(';','or'):- !.
  33. into_cycl_form(A,AA):- atomic(A),!,A=AA.
  34. into_cycl_form((A:-B),'sentenceImplies'(BB,AA)):- cycl_2, !, into_cycl_form(A,AA),into_cycl_form(B,BB).
  35. into_cycl_form((A:-B),'implies'(BB,AA)):- !, into_cycl_form(A,AA),into_cycl_form(B,BB).
  36. into_cycl_form(M:P,AA):- \+ atomic(P),!,into_cycl_form(ist(M,P),AA).
  37. into_cycl_form(A,AA):- A=..AL, maplist(into_cycl_form,AL,AA).
  38.  
  39.  
  40.  
  41. unify_cycl_form(Binding,Binding):- (var(Binding);number(Binding)),!.
  42. unify_cycl_form(string(B),string(B)):-!.
  43. unify_cycl_form(Binding,BindingP):-atom(Binding),atom_concat('#$',BindingP,Binding),!.
  44. unify_cycl_form(nart(B),nart(BB)):-unify_cycl_form(B,BB),!.
  45. unify_cycl_form(nart(B),(BB)):-!,unify_cycl_form(B,BB),!.
  46. %unify_cycl_form(string(B),List):-atomSplit(List,B),!.
  47. unify_cycl_form(string(B),B):-!.
  48. unify_cycl_form(string([]),""):-!.
  49. unify_cycl_form(quote(B),BO):-!,unify_cycl_form(B,BO).
  50. unify_cycl_form([A|L],Binding):-unify_cycl_formCons(A,L,Binding),!.
  51. unify_cycl_form(Binding,Binding):-!.
  52.  
  53. unify_cycl_formCons(A,L,[A|L]):- (var(A);var(L);A=string(_);number(A)),!.
  54. % unify_cycl_formCons('and-also',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  55. % unify_cycl_formCons('eval',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  56. % unify_cycl_formCons('#$and-also',L,Binding):-unify_cycl_formS(L,LO), list_to_conj(LO,Binding),!.
  57. unify_cycl_formCons(A,L,Binding):-
  58.      unify_cycl_form(A,AO),
  59.          unify_cycl_formCons(A,AO,L,Binding).
  60. unify_cycl_formCons(A,AO,L,Binding):-
  61.          atom(AO),!,
  62.      unify_cycl_formS(L,LO),
  63.      Binding=..[AO|LO],!.
  64. unify_cycl_formCons(A,AO,L,Binding):-
  65.      unify_cycl_formS(L,LO),
  66.      Binding=[AO|LO],!.
  67.  
  68. unify_cycl_formS(Binding,Binding):- (var(Binding);atom(Binding);number(Binding)),!.
  69. unify_cycl_formS([],[]).
  70. unify_cycl_formS([V,[L]|M],[LL|ML]):- nonvar(V), cl_quote(V),unify_cycl_formS(L,LL),unify_cycl_formS(M,ML).
  71. 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