
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 0.89 KB | hits: 14 | expires: Never
Has anybody seen a good open source Prolog implementation of the SATCHMO theorem prover?
:- op(1200, xfx, '--->').
:- unknown(_, fail).
satisfiable :-
setof(Clause, violated_instance(Clause), Clauses),
!,
satisfy_all(Clauses),
satisfiable.
satisfiable.
violated_instance((B ---> H)) :-
(B ---> H),
B,
+ H.
satisfy_all([]).
satisfy_all([(_B ---> H) | RestClauses]) :-
H,
!,
satisfy_all(RestClauses).
satisfy_all([(_B ---> H) | RestClauses]) :-
satisfy(H),
satisfy_all(RestClauses).
/*
satisfy((A,B)) :-
!,
satisfy(A),
satisfy(B).
*/
satisfy((A;B)) :-
!,
(satisfy(A) ; satisfy(B)).
satisfy(Atom) :-
+ Atom = untrue,
(
predicate_property(Atom, built_in)
->
call(Atom)
;
assume(Atom)
).
assume(Atom) :-
% nl, write(['Asserting ': Atom]),
asserta(Atom).
assume(Atom) :-
% nl, write(['Retracting ': Atom]),
retract(Atom),
!,
fail.