Advertisement
logicmoo

Untitled

Sep 22nd, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 2.53 KB | None | 0 0
  1. #!/usr/bin/env swipl
  2. /**
  3. ````
  4. */
  5. :- if(gethostname(ubuntu)).
  6. :- user:ensure_loaded(logicmoo_repl).
  7. :- else.
  8. :- load_files(logicmoo_repl, [if(not_loaded),qcompile(auto)]).
  9. :- endif.
  10.  
  11.  
  12. :-multifile shared_hide_data/1.
  13. shared_hide_data(hideMeta):-is_main_thread.
  14. shared_hide_data(hideTriggers):-is_main_thread.
  15.  
  16. % setup pfc
  17. :- file_begin(pfc).
  18.  
  19. % see logicmoo_i_compiler.pl for more info
  20. :- set_clause_compile(fwc).
  21.  
  22. % Logical Negation (not by failure)
  23. ==> clif(male(P)  => ~ female(P)).
  24.  
  25.  
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. % kif :-
  28. %       all(P, (male(P)=> ~female(P))).
  29. %
  30. % pkif :-
  31. %       all(P, (male(P)=>not(female(P)))).
  32. %
  33. % cnf :-
  34. %       not(male(P))v not(female(P)).
  35. %
  36. % horn :-
  37. %       [ (not(female(P)):-male(P)), (not(male(P)):-female(P))].
  38. %
  39. % succeed(user:kif_to_boxlog((male(P)=> ~female(P)), [ (not(female(P)):-male(P)), (not(male(P)):-female(P))])).
  40. %
  41. % succeed(user:boxlog_to_pfc((not(female(P)):-male(P)), (male(P), {is_unit(P)}==>neg(female(P))))).
  42. %
  43. % succeed(user:boxlog_to_pfc((not(male(P)):-female(P)), (female(P), {is_unit(P)}==>neg(male(P))))).
  44. %
  45. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  46.  
  47. ==> male(joe).
  48. ==> ~female(pat).
  49.  
  50. % Humans are male or female
  51. ==> clif(human(P) => (female(P) v male(P))).
  52.  
  53. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54. % kif :-
  55. %       all(P, (human(P)=>female(P)v male(P))).
  56. %
  57. % pkif :-
  58. %       all(P, (human(P)=>female(P)v male(P))).
  59. %
  60. % cnf :-
  61. %       not(human(P))v (female(P)v male(P)).
  62. %
  63. % horn :-
  64. %
  65. %       [ (female(P):-human(P), not(male(P))),
  66. %         (male(P):-human(P), not(female(P))),
  67. %         (not(human(P)):-not(female(P)), not(male(P)))
  68. %       ].
  69. %
  70. % succeed(user:kif_to_boxlog((human(P)=>female(P)v male(P)), [ (female(P):-human(P), not(male(P))), (male(P):-human(P), not(female(P))), (not(human(P)):-not(female(P)), not(male(P)))])).
  71. %
  72. % succeed(user:boxlog_to_pfc((female(P):-human(P), not(male(P))), (human(P), neg(male(P)), {is_unit(P)}==>female(P)))).
  73. %
  74. % succeed(user:boxlog_to_pfc((male(P):-human(P), not(female(P))), (human(P), neg(female(P)), {is_unit(P)}==>male(P)))).
  75. %
  76. % succeed(user:boxlog_to_pfc((not(human(P)):-not(female(P)), not(male(P))), (neg(female(P)), neg(male(P)), {is_unit(P)}==>neg(human(P))))).
  77. %
  78. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  79.  
  80.  
  81.  
  82. % We check that we cannot prove Pat is male.
  83. % Thus a query to ?- male(pat ).
  84. :- test_is_failure( male(pat )).
  85.  
  86. % Assert pat is human
  87. ==> human(pat).
  88.  
  89. % Thus we can deduce he is male now
  90. :- test_is_success( male(pat )).
  91.  
  92.  
  93.  
  94. :-prolog.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement