equal
deleted
inserted
replaced
1 |
1 |
2 |
2 |
3 (*----------------------------------------------*) |
3 (*----------------------------------------------*) |
4 (* Reorder clauses for use in binary resolution *) |
4 (* Reorder clauses for use in binary resolution *) |
5 (*----------------------------------------------*) |
5 (*----------------------------------------------*) |
6 fun take n [] = [] |
|
7 | take n (x::xs) = (if n = 0 then [] else (x::(take (n - 1) xs))) |
|
8 |
6 |
9 fun drop n [] = [] |
7 fun drop n [] = [] |
10 | drop n (x::xs) = (if n = 0 then (x::xs) else drop (n-1) xs) |
8 | drop n (x::xs) = (if n = 0 then (x::xs) else drop (n-1) xs) |
11 |
9 |
12 fun remove n [] = [] |
10 fun remove n [] = [] |
13 | remove n (x::xs) = List.filter (not_equal n) (x::xs); |
11 | remove n (x::xs) = List.filter (not_equal n) (x::xs); |
14 |
12 |
15 fun remove_nth n [] = [] |
13 fun remove_nth n [] = [] |
16 | remove_nth n (x::xs) = (take (n -1) (x::xs))@(drop n (x::xs)) |
14 | remove_nth n xs = (List.take (xs, n-1)) @ (List.drop (xs, n)) |
17 |
15 |
18 fun get_nth n (x::xs) = hd (drop (n-1) (x::xs)) |
16 fun get_nth n (x::xs) = hd (drop (n-1) (x::xs)) |
19 |
17 |
20 |
18 |
21 fun literals (Const("Trueprop",_) $ P) = literals P |
19 fun literals (Const("Trueprop",_) $ P) = literals P |
26 (*number of literals in a term*) |
24 (*number of literals in a term*) |
27 val nliterals = length o literals; |
25 val nliterals = length o literals; |
28 |
26 |
29 exception Not_in_list; |
27 exception Not_in_list; |
30 |
28 |
31 |
|
32 |
|
33 |
|
34 (* get the literals from a disjunctive clause *) |
|
35 |
|
36 (*fun get_disj_literals t = if is_disj t then |
|
37 let |
|
38 val {disj1, disj2} = dest_disj t |
|
39 in |
|
40 disj1::(get_disj_literals disj2) |
|
41 end |
|
42 else |
|
43 ([t]) |
|
44 |
|
45 *) |
|
46 |
29 |
47 (* |
30 (* |
48 (* gives horn clause with kth disj as concl (starting at 1) *) |
31 (* gives horn clause with kth disj as concl (starting at 1) *) |
49 fun rots (0,th) = (Meson.make_horn Meson.crules th) |
32 fun rots (0,th) = (Meson.make_horn Meson.crules th) |
50 | rots (k,th) = rots(k-1, assoc_right (th RS disj_comm)) |
33 | rots (k,th) = rots(k-1, assoc_right (th RS disj_comm)) |
97 val nliterals = length o literals; |
80 val nliterals = length o literals; |
98 |
81 |
99 exception Not_in_list; |
82 exception Not_in_list; |
100 |
83 |
101 |
84 |
102 (*Permute a rule's premises to move the i-th premise to the last position.*) |
|
103 fun make_last i th = |
|
104 let val n = nprems_of th |
|
105 in if 1 <= i andalso i <= n |
|
106 then Thm.permute_prems (i-1) 1 th |
|
107 else raise THM("make_last", i, [th]) |
|
108 end; |
|
109 |
|
110 (*Maps a rule that ends "... ==> P ==> False" to "... ==> ~P" while suppressing |
|
111 double-negations.*) |
|
112 val negate_head = rewrite_rule [atomize_not, not_not RS eq_reflection]; |
|
113 |
|
114 (*Maps the clause [P1,...Pn]==>False to [P1,...,P(i-1),P(i+1),...Pn] ==> ~P*) |
|
115 fun select_literal i cl = negate_head (make_last i cl); |
|
116 |
|
117 |
|
118 (* get a meta-clause for resolution with correct order of literals *) |
85 (* get a meta-clause for resolution with correct order of literals *) |
119 fun get_meta_cl (th,n) = let val lits = nliterals(prop_of th) |
86 fun get_meta_cl (th,n) = let val lits = nliterals(prop_of th) |
120 val contra = if lits = 1 |
87 val contra = if lits = 1 |
121 then |
88 then |
122 th |
89 th |
128 |
95 |
129 contra |
96 contra |
130 else |
97 else |
131 rotate_prems (lits - n) contra |
98 rotate_prems (lits - n) contra |
132 end |
99 end |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
100 |
138 |
101 |
139 |
102 |
140 fun zip xs [] = [] |
103 fun zip xs [] = [] |
141 | zip xs (y::ys) = (case xs of [] => [] | (z::zs) => ((z,y)::zip zs ys)) |
104 | zip xs (y::ys) = (case xs of [] => [] | (z::zs) => ((z,y)::zip zs ys)) |
379 end |
342 end |
380 |
343 |
381 *) |
344 *) |
382 |
345 |
383 |
346 |
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 (* checkorder Spass Isabelle [] *) |
347 (* checkorder Spass Isabelle [] *) |
393 |
348 |
394 fun checkorder [] strlist allvars (numlist, symlist, not_symlist)= (numlist,symlist, not_symlist) |
349 fun checkorder [] strlist allvars (numlist, symlist, not_symlist)= (numlist,symlist, not_symlist) |
395 | checkorder (x::xs) strlist allvars (numlist, symlist, not_symlist) = |
350 | checkorder (x::xs) strlist allvars (numlist, symlist, not_symlist) = |
396 let val (posnum, symlist', not_symlist') = pos_in_list x strlist allvars (0, symlist, not_symlist) |
351 let val (posnum, symlist', not_symlist') = pos_in_list x strlist allvars (0, symlist, not_symlist) |