-
Notifications
You must be signed in to change notification settings - Fork 4
/
printers.pro
80 lines (70 loc) · 1.29 KB
/
printers.pro
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
p1:- do((s_(T),varvars(T,TT),(qqq(TT);ppt(TT)))).
pph(Horns):-is_list(Horns),!,
do((
member(H,Horns),
pph(H),nl
)),
nl.
pph(Horn):-horn2term(Horn,Term),ppt(Term).
showImpForms(N):-
do((
genTree(N,T,Vs),
vpartitions(Vs),
ppp(T)
)).
showSortedHorn(N):-
do((
allSortedHorn(N,T),
ppt(T),
hdepth(T,D),
ppp(D),
nl
)).
showFlatHorn:-
tell('docs/horn3big.txt'),
showFlatHorn(9),
told.
showFlatHorn(N):-
do((
allSortedHorn(N,T0),
ppp(before=T0),nl,
pph(T0),nl,
(ljh(T0)->R0=true;R0=false),
flattenHorn(T0,T),
ppp(after_=T),nl,
pph(T),nl,
hdepth(T,D),
(ljh(T)->R=true;R=false),
ppp([taut=R0+R,depth=D]),
ppp('--------------------------'),
nl,
assertion(R0=R),
assertion(D=<3)
)).
showFlatImp(N):-
do((
allSortedHorn(N,T0),
toHorn(A0,T0),
ppp(A0),
%ppt(A0),
nl,
flattenHorn(T0,T),
toHorn(A,T),
ppp(A),
ppt(A),
left_depth(A,D),assertion(D=<3),
nl,
(D>=3->ppp(D);true),
ppp('------------')
)).
left_depth(A,R):-(atomic(A);var(A)),!,R=0.
left_depth(A->_,R):-left_depth(A,D),R is D+1.
showSortedHorns(N):-
do((
allSortedHorn(N,T),
ppp(T),
horn2term(T,Pro),
pph(T),
ppp(Pro),
nl
)).