53 |
53 |
54 fun strip_one name (Const ("all", _) $ Abs (s, T, Const ("==>", _) $ P $ Q)) = |
54 fun strip_one name (Const ("all", _) $ Abs (s, T, Const ("==>", _) $ P $ Q)) = |
55 (subst_bound (Free (name, T), P), subst_bound (Free (name, T), Q)) |
55 (subst_bound (Free (name, T), P), subst_bound (Free (name, T), Q)) |
56 | strip_one _ (Const ("==>", _) $ P $ Q) = (P, Q); |
56 | strip_one _ (Const ("==>", _) $ P $ Q) = (P, Q); |
57 |
57 |
58 fun relevant_vars prop = foldr (fn |
58 fun relevant_vars prop = List.foldr (fn |
59 (Var ((a, i), T), vs) => (case strip_type T of |
59 (Var ((a, i), T), vs) => (case strip_type T of |
60 (_, Type (s, _)) => if s mem ["bool"] then (a, T) :: vs else vs |
60 (_, Type (s, _)) => if s mem ["bool"] then (a, T) :: vs else vs |
61 | _ => vs) |
61 | _ => vs) |
62 | (_, vs) => vs) [] (OldTerm.term_vars prop); |
62 | (_, vs) => vs) [] (OldTerm.term_vars prop); |
63 |
63 |
262 val rs = map Var (subtract (op = o pairself fst) xs rlzvs); |
262 val rs = map Var (subtract (op = o pairself fst) xs rlzvs); |
263 val rlz' = fold_rev Logic.all (vs2 @ rs) (prop_of rrule); |
263 val rlz' = fold_rev Logic.all (vs2 @ rs) (prop_of rrule); |
264 val rlz'' = fold_rev Logic.all vs2 rlz |
264 val rlz'' = fold_rev Logic.all vs2 rlz |
265 in (name, (vs, |
265 in (name, (vs, |
266 if rt = Extraction.nullt then rt else |
266 if rt = Extraction.nullt then rt else |
267 foldr (uncurry lambda) rt vs1, |
267 List.foldr (uncurry lambda) rt vs1, |
268 ProofRewriteRules.un_hhf_proof rlz' rlz'' |
268 ProofRewriteRules.un_hhf_proof rlz' rlz'' |
269 (fold_rev forall_intr_prf (vs2 @ rs) (prf_of rrule)))) |
269 (fold_rev forall_intr_prf (vs2 @ rs) (prf_of rrule)))) |
270 end; |
270 end; |
271 |
271 |
272 fun rename tab = map (fn x => the_default x (AList.lookup op = tab x)); |
272 fun rename tab = map (fn x => the_default x (AList.lookup op = tab x)); |
313 ||> Extraction.add_typeof_eqns_i ty_eqs |
313 ||> Extraction.add_typeof_eqns_i ty_eqs |
314 ||> Extraction.add_realizes_eqns_i rlz_eqs; |
314 ||> Extraction.add_realizes_eqns_i rlz_eqs; |
315 fun get f = (these oo Option.map) f; |
315 fun get f = (these oo Option.map) f; |
316 val rec_names = distinct (op =) (map (fst o dest_Const o head_of o fst o |
316 val rec_names = distinct (op =) (map (fst o dest_Const o head_of o fst o |
317 HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) (get #rec_thms dt_info)); |
317 HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) (get #rec_thms dt_info)); |
318 val (_, constrss) = foldl_map (fn ((recs, dummies), (s, rs)) => |
318 val (_, constrss) = Library.foldl_map (fn ((recs, dummies), (s, rs)) => |
319 if s mem rsets then |
319 if s mem rsets then |
320 let |
320 let |
321 val (d :: dummies') = dummies; |
321 val (d :: dummies') = dummies; |
322 val (recs1, recs2) = chop (length rs) (if d then tl recs else recs) |
322 val (recs1, recs2) = chop (length rs) (if d then tl recs else recs) |
323 in ((recs2, dummies'), map (head_of o hd o rev o snd o strip_comb o |
323 in ((recs2, dummies'), map (head_of o hd o rev o snd o strip_comb o |