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) = Library.foldl_map (fn ((recs, dummies), (s, rs)) => |
318 val (constrss, _) = fold_map (fn (s, rs) => fn (recs, dummies) => |
319 if s mem rsets then |
319 if member (op =) rsets s 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 (map (head_of o hd o rev o snd o strip_comb o fst o |
324 fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) recs1) |
324 HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) recs1, (recs2, dummies')) |
325 end |
325 end |
326 else ((recs, dummies), replicate (length rs) Extraction.nullt)) |
326 else (replicate (length rs) Extraction.nullt, (recs, dummies))) |
327 ((get #rec_thms dt_info, dummies), rss); |
327 rss (get #rec_thms dt_info, dummies); |
328 val rintrs = map (fn (intr, c) => Envir.eta_contract |
328 val rintrs = map (fn (intr, c) => Envir.eta_contract |
329 (Extraction.realizes_of thy2 vs |
329 (Extraction.realizes_of thy2 vs |
330 (if c = Extraction.nullt then c else list_comb (c, map Var (rev |
330 (if c = Extraction.nullt then c else list_comb (c, map Var (rev |
331 (Term.add_vars (prop_of intr) []) \\ params'))) (prop_of intr))) |
331 (Term.add_vars (prop_of intr) []) \\ params'))) (prop_of intr))) |
332 (maps snd rss ~~ List.concat constrss); |
332 (maps snd rss ~~ List.concat constrss); |
358 Sign.root_path; |
358 Sign.root_path; |
359 val thy3 = fold (PureThy.hide_fact false o name_of_thm) (#intrs ind_info) thy3'; |
359 val thy3 = fold (PureThy.hide_fact false o name_of_thm) (#intrs ind_info) thy3'; |
360 |
360 |
361 (** realizer for induction rule **) |
361 (** realizer for induction rule **) |
362 |
362 |
363 val Ps = List.mapPartial (fn _ $ M $ P => if pred_of M mem rsets then |
363 val Ps = map_filter (fn _ $ M $ P => if pred_of M mem rsets then |
364 SOME (fst (fst (dest_Var (head_of P)))) else NONE) |
364 SOME (fst (fst (dest_Var (head_of P)))) else NONE) |
365 (HOLogic.dest_conj (HOLogic.dest_Trueprop (concl_of raw_induct))); |
365 (HOLogic.dest_conj (HOLogic.dest_Trueprop (concl_of raw_induct))); |
366 |
366 |
367 fun add_ind_realizer (thy, Ps) = |
367 fun add_ind_realizer (thy, Ps) = |
368 let |
368 let |