21 val strip_prems: int * term list * term -> term list * term |
21 val strip_prems: int * term list * term -> term list * term |
22 val count_prems: term * int -> int |
22 val count_prems: term * int -> int |
23 val nth_prem: int * term -> term |
23 val nth_prem: int * term -> term |
24 val mk_conjunction: term * term -> term |
24 val mk_conjunction: term * term -> term |
25 val mk_conjunction_list: term list -> term |
25 val mk_conjunction_list: term list -> term |
|
26 val mk_conjunction_list2: term list list -> term |
26 val dest_conjunction: term -> term * term |
27 val dest_conjunction: term -> term * term |
27 val dest_conjunctions: term -> term list |
28 val dest_conjunctions: term -> term list |
28 val strip_horn: term -> term list * term |
29 val strip_horn: term -> term list * term |
29 val mk_cond_defpair: term list -> term * term -> string * term |
30 val mk_cond_defpair: term list -> term * term -> string * term |
30 val mk_defpair: term * term -> string * term |
31 val mk_defpair: term * term -> string * term |
129 fun strip_horn A = (strip_imp_prems A, strip_imp_concl A); |
130 fun strip_horn A = (strip_imp_prems A, strip_imp_concl A); |
130 |
131 |
131 |
132 |
132 (** conjunction **) |
133 (** conjunction **) |
133 |
134 |
|
135 (*A && B*) |
134 fun mk_conjunction (t, u) = |
136 fun mk_conjunction (t, u) = |
135 Term.list_all ([("X", propT)], |
137 Term.list_all ([("X", propT)], |
136 mk_implies (list_implies (map (Term.incr_boundvars 1) [t, u], Bound 0), Bound 0)); |
138 mk_implies (list_implies (map (Term.incr_boundvars 1) [t, u], Bound 0), Bound 0)); |
137 |
139 |
|
140 (*A && B && C -- improper*) |
138 fun mk_conjunction_list [] = Term.all propT $ Abs ("dummy", propT, mk_implies (Bound 0, Bound 0)) |
141 fun mk_conjunction_list [] = Term.all propT $ Abs ("dummy", propT, mk_implies (Bound 0, Bound 0)) |
139 | mk_conjunction_list ts = foldr1 mk_conjunction ts; |
142 | mk_conjunction_list ts = foldr1 mk_conjunction ts; |
140 |
143 |
|
144 (*(A1 && B1 && C1) && (A2 && B2 && C2 && D2) && A3 && B3 -- improper*) |
|
145 fun mk_conjunction_list2 tss = |
|
146 mk_conjunction_list (map mk_conjunction_list (filter_out null tss)); |
|
147 |
|
148 (*A && B*) |
141 fun dest_conjunction |
149 fun dest_conjunction |
142 (t as Const ("all", _) $ Abs (_, _, |
150 (t as Const ("all", _) $ Abs (_, _, |
143 Const ("==>", _) $ (Const ("==>", _) $ A $ (Const ("==>", _) $ B $ Bound 0)) $ Bound 0)) = |
151 Const ("==>", _) $ (Const ("==>", _) $ A $ (Const ("==>", _) $ B $ Bound 0)) $ Bound 0)) = |
144 if Term.loose_bvar1 (A, 0) orelse Term.loose_bvar1 (B, 0) |
152 if Term.loose_bvar1 (A, 0) orelse Term.loose_bvar1 (B, 0) |
145 then raise TERM ("dest_conjunction", [t]) |
153 then raise TERM ("dest_conjunction", [t]) |
146 else (Term.incr_boundvars ~1 A, Term.incr_boundvars ~1 B) |
154 else (Term.incr_boundvars ~1 A, Term.incr_boundvars ~1 B) |
147 | dest_conjunction t = raise TERM ("dest_conjunction", [t]); |
155 | dest_conjunction t = raise TERM ("dest_conjunction", [t]); |
148 |
156 |
|
157 (*((A && B) && C) && D && E -- flat*) |
149 fun dest_conjunctions t = |
158 fun dest_conjunctions t = |
150 (case try dest_conjunction t of |
159 (case try dest_conjunction t of |
151 NONE => [t] |
160 NONE => [t] |
152 | SOME (A, B) => dest_conjunctions A @ dest_conjunctions B); |
161 | SOME (A, B) => dest_conjunctions A @ dest_conjunctions B); |
153 |
162 |