changeset 6427 | fd36b2e7d80e |
parent 6422 | 965705537d5b |
child 6522 | 2f6cec5c046f |
6426:9a2ace82b68e | 6427:fd36b2e7d80e |
---|---|
58 |
58 |
59 (************************ case distinction theorems ***************************) |
59 (************************ case distinction theorems ***************************) |
60 |
60 |
61 fun prove_casedist_thms new_type_names descr sorts induct thy = |
61 fun prove_casedist_thms new_type_names descr sorts induct thy = |
62 let |
62 let |
63 val _ = message "Proving case distinction theorems..."; |
63 val _ = message "Proving case distinction theorems ..."; |
64 |
64 |
65 val descr' = flat descr; |
65 val descr' = flat descr; |
66 val recTs = get_rec_types descr' sorts; |
66 val recTs = get_rec_types descr' sorts; |
67 val newTs = take (length (hd descr), recTs); |
67 val newTs = take (length (hd descr), recTs); |
68 |
68 |
97 (*************************** primrec combinators ******************************) |
97 (*************************** primrec combinators ******************************) |
98 |
98 |
99 fun prove_primrec_thms flat_names new_type_names descr sorts |
99 fun prove_primrec_thms flat_names new_type_names descr sorts |
100 (dt_info : datatype_info Symtab.table) constr_inject dist_rewrites induct thy = |
100 (dt_info : datatype_info Symtab.table) constr_inject dist_rewrites induct thy = |
101 let |
101 let |
102 val _ = message "Constructing primrec combinators..."; |
102 val _ = message "Constructing primrec combinators ..."; |
103 |
103 |
104 val big_name = space_implode "_" new_type_names; |
104 val big_name = space_implode "_" new_type_names; |
105 val thy0 = add_path flat_names big_name thy; |
105 val thy0 = add_path flat_names big_name thy; |
106 |
106 |
107 val descr' = flat descr; |
107 val descr' = flat descr; |
172 (InductivePackage.add_inductive_i false true big_rec_name' false false true |
172 (InductivePackage.add_inductive_i false true big_rec_name' false false true |
173 rec_sets (map (fn x => (("", x), [])) rec_intr_ts) [] []) thy0; |
173 rec_sets (map (fn x => (("", x), [])) rec_intr_ts) [] []) thy0; |
174 |
174 |
175 (* prove uniqueness and termination of primrec combinators *) |
175 (* prove uniqueness and termination of primrec combinators *) |
176 |
176 |
177 val _ = message "Proving termination and uniqueness of primrec functions..."; |
177 val _ = message "Proving termination and uniqueness of primrec functions ..."; |
178 |
178 |
179 fun mk_unique_tac ((tac, intrs), ((((i, (tname, _, constrs)), elim), T), T')) = |
179 fun mk_unique_tac ((tac, intrs), ((((i, (tname, _, constrs)), elim), T), T')) = |
180 let |
180 let |
181 val distinct_tac = (etac Pair_inject 1) THEN |
181 val distinct_tac = (etac Pair_inject 1) THEN |
182 (if i < length newTs then |
182 (if i < length newTs then |
261 |
261 |
262 val reccomb_defs = map ((get_def thy2) o Sign.base_name) reccomb_names; |
262 val reccomb_defs = map ((get_def thy2) o Sign.base_name) reccomb_names; |
263 |
263 |
264 (* prove characteristic equations for primrec combinators *) |
264 (* prove characteristic equations for primrec combinators *) |
265 |
265 |
266 val _ = message "Proving characteristic theorems for primrec combinators..." |
266 val _ = message "Proving characteristic theorems for primrec combinators ..." |
267 |
267 |
268 val rec_thms = map (fn t => prove_goalw_cterm reccomb_defs |
268 val rec_thms = map (fn t => prove_goalw_cterm reccomb_defs |
269 (cterm_of (Theory.sign_of thy2) t) (fn _ => |
269 (cterm_of (Theory.sign_of thy2) t) (fn _ => |
270 [rtac select1_equality 1, |
270 [rtac select1_equality 1, |
271 resolve_tac rec_unique_thms 1, |
271 resolve_tac rec_unique_thms 1, |
282 |
282 |
283 (***************************** case combinators *******************************) |
283 (***************************** case combinators *******************************) |
284 |
284 |
285 fun prove_case_thms flat_names new_type_names descr sorts reccomb_names primrec_thms thy = |
285 fun prove_case_thms flat_names new_type_names descr sorts reccomb_names primrec_thms thy = |
286 let |
286 let |
287 val _ = message "Proving characteristic theorems for case combinators..."; |
287 val _ = message "Proving characteristic theorems for case combinators ..."; |
288 |
288 |
289 val thy1 = add_path flat_names (space_implode "_" new_type_names) thy; |
289 val thy1 = add_path flat_names (space_implode "_" new_type_names) thy; |
290 |
290 |
291 val descr' = flat descr; |
291 val descr' = flat descr; |
292 val recTs = get_rec_types descr' sorts; |
292 val recTs = get_rec_types descr' sorts; |
428 (******************************* case splitting *******************************) |
428 (******************************* case splitting *******************************) |
429 |
429 |
430 fun prove_split_thms new_type_names descr sorts constr_inject dist_rewrites |
430 fun prove_split_thms new_type_names descr sorts constr_inject dist_rewrites |
431 casedist_thms case_thms thy = |
431 casedist_thms case_thms thy = |
432 let |
432 let |
433 val _ = message "Proving equations for case splitting..."; |
433 val _ = message "Proving equations for case splitting ..."; |
434 |
434 |
435 val descr' = flat descr; |
435 val descr' = flat descr; |
436 val recTs = get_rec_types descr' sorts; |
436 val recTs = get_rec_types descr' sorts; |
437 val newTs = take (length (hd descr), recTs); |
437 val newTs = take (length (hd descr), recTs); |
438 |
438 |
464 |
464 |
465 (******************************* size functions *******************************) |
465 (******************************* size functions *******************************) |
466 |
466 |
467 fun prove_size_thms flat_names new_type_names descr sorts reccomb_names primrec_thms thy = |
467 fun prove_size_thms flat_names new_type_names descr sorts reccomb_names primrec_thms thy = |
468 let |
468 let |
469 val _ = message "Proving equations for size function..."; |
469 val _ = message "Proving equations for size function ..."; |
470 |
470 |
471 val big_name = space_implode "_" new_type_names; |
471 val big_name = space_implode "_" new_type_names; |
472 val thy1 = add_path flat_names big_name thy; |
472 val thy1 = add_path flat_names big_name thy; |
473 |
473 |
474 val descr' = flat descr; |
474 val descr' = flat descr; |
525 |
525 |
526 (************************* additional theorems for TFL ************************) |
526 (************************* additional theorems for TFL ************************) |
527 |
527 |
528 fun prove_nchotomys new_type_names descr sorts casedist_thms thy = |
528 fun prove_nchotomys new_type_names descr sorts casedist_thms thy = |
529 let |
529 let |
530 val _ = message "Proving additional theorems for TFL..."; |
530 val _ = message "Proving additional theorems for TFL ..."; |
531 |
531 |
532 fun prove_nchotomy (t, exhaustion) = |
532 fun prove_nchotomy (t, exhaustion) = |
533 let |
533 let |
534 (* For goal i, select the correct disjunct to attack, then prove it *) |
534 (* For goal i, select the correct disjunct to attack, then prove it *) |
535 fun tac i 0 = EVERY [TRY (rtac disjI1 i), |
535 fun tac i 0 = EVERY [TRY (rtac disjI1 i), |