Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env swipl
- /**
- ````
- */
- :- if(gethostname(ubuntu)).
- :- user:ensure_loaded(logicmoo_repl).
- :- else.
- :- load_files(logicmoo_repl, [if(not_loaded),qcompile(auto)]).
- :- endif.
- :-multifile shared_hide_data/1.
- shared_hide_data(hideMeta):-is_main_thread.
- shared_hide_data(hideTriggers):-is_main_thread.
- % setup pfc
- :- file_begin(pfc).
- % see logicmoo_i_compiler.pl for more info
- :- set_clause_compile(fwc).
- % Logical Negation (not by failure)
- ==> clif(male(P) => ~ female(P)).
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % kif :-
- % all(P, (male(P)=> ~female(P))).
- %
- % pkif :-
- % all(P, (male(P)=>not(female(P)))).
- %
- % cnf :-
- % not(male(P))v not(female(P)).
- %
- % horn :-
- % [ (not(female(P)):-male(P)), (not(male(P)):-female(P))].
- %
- % succeed(user:kif_to_boxlog((male(P)=> ~female(P)), [ (not(female(P)):-male(P)), (not(male(P)):-female(P))])).
- %
- % succeed(user:boxlog_to_pfc((not(female(P)):-male(P)), (male(P), {is_unit(P)}==>neg(female(P))))).
- %
- % succeed(user:boxlog_to_pfc((not(male(P)):-female(P)), (female(P), {is_unit(P)}==>neg(male(P))))).
- %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- ==> male(joe).
- ==> ~female(pat).
- % Humans are male or female
- ==> clif(human(P) => (female(P) v male(P))).
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % kif :-
- % all(P, (human(P)=>female(P)v male(P))).
- %
- % pkif :-
- % all(P, (human(P)=>female(P)v male(P))).
- %
- % cnf :-
- % not(human(P))v (female(P)v male(P)).
- %
- % horn :-
- %
- % [ (female(P):-human(P), not(male(P))),
- % (male(P):-human(P), not(female(P))),
- % (not(human(P)):-not(female(P)), not(male(P)))
- % ].
- %
- % 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)))])).
- %
- % succeed(user:boxlog_to_pfc((female(P):-human(P), not(male(P))), (human(P), neg(male(P)), {is_unit(P)}==>female(P)))).
- %
- % succeed(user:boxlog_to_pfc((male(P):-human(P), not(female(P))), (human(P), neg(female(P)), {is_unit(P)}==>male(P)))).
- %
- % 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))))).
- %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % We check that we cannot prove Pat is male.
- % Thus a query to ?- male(pat ).
- :- test_is_failure( male(pat )).
- % Assert pat is human
- ==> human(pat).
- % Thus we can deduce he is male now
- :- test_is_success( male(pat )).
- :-prolog.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement