-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.pl
41 lines (33 loc) · 897 Bytes
/
base.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
proposition(T,P) :- pred_sym(T,P).
proposition(T,not(P)) :- proposition(T,P).
negate([],[]).
negate([P|Ps],NPs1) :-
complementary(P,NP),
negate(Ps,NPs),
ord_add_element(NPs,NP,NPs1).
complementary(not(P),P) :- !.
complementary(P,not(P)).
unsat(A) :-
member(not(X=X),A), !.
unsat(A) :-
member(X,A),
complementary(X,XC),
member(XC,A), !.
select_equs([],[],[]).
select_equs([X=Y|Ls],[X=Y|Es],Rs) :- !,
select_equs(Ls,Es,Rs).
select_equs([L|Ls],Es,[L|Rs]) :-
select_equs(Ls,Es,Rs).
clause_to_oclause([],[]).
clause_to_oclause([L|Ls],OC2) :-
clause_to_oclause(Ls,OC1),
add_lit_to_oclause(OC1,L,OC2).
add_lit_to_oclause([],L,[L]).
add_lit_to_oclause([L|OC],L1,[L1,L|OC]) :-
lit_lte(L1,L), !.
add_lit_to_oclause([L|OC],L1,[L|OC1]) :-
add_lit_to_oclause(OC,L1,OC1).
lit_lte(not(X),not(Y)) :- !, X @=< Y.
lit_lte(_,not(_)) :- !.
lit_lte(not(_),_) :- !, fail.
lit_lte(X,Y) :- X @=< Y.