equal
deleted
inserted
replaced
355 $ ((t0 as Const (@{const_name HOL.eq}, _)) $ t1 $ t2))) = |
355 $ ((t0 as Const (@{const_name HOL.eq}, _)) $ t1 $ t2))) = |
356 if Term_Ord.fast_term_ord (t1, t2) <> GREATER then t |
356 if Term_Ord.fast_term_ord (t1, t2) <> GREATER then t |
357 else HOLogic.mk_Trueprop (HOLogic.mk_not (t0 $ t2 $ t1)) |
357 else HOLogic.mk_Trueprop (HOLogic.mk_not (t0 $ t2 $ t1)) |
358 | normalize_eq t = t |
358 | normalize_eq t = t |
359 |
359 |
360 val normalize_eq_etc = normalize_eq o Term_Subst.zero_var_indexes |
360 val normalize_eq_vars = normalize_eq #> normalize_vars |
361 |
361 |
362 fun if_thm_before th th' = |
362 fun if_thm_before th th' = |
363 if Theory.subthy (pairself Thm.theory_of_thm (th, th')) then th else th' |
363 if Theory.subthy (pairself Thm.theory_of_thm (th, th')) then th else th' |
364 |
364 |
365 (* Hack: Conflate the facts about a class as seen from the outside with the |
365 (* Hack: Conflate the facts about a class as seen from the outside with the |
370 SOME (pref, suf) => [s, pref ^ suf] |
370 SOME (pref, suf) => [s, pref ^ suf] |
371 | NONE => [s] |
371 | NONE => [s] |
372 |
372 |
373 fun build_name_tables name_of facts = |
373 fun build_name_tables name_of facts = |
374 let |
374 let |
375 fun cons_thm (_, th) = Termtab.cons_list (normalize_eq_etc (prop_of th), th) |
375 fun cons_thm (_, th) = |
|
376 Termtab.cons_list (normalize_eq_vars (prop_of th), th) |
376 fun add_plain canon alias = |
377 fun add_plain canon alias = |
377 Symtab.update (Thm.get_name_hint alias, |
378 Symtab.update (Thm.get_name_hint alias, |
378 name_of (if_thm_before canon alias)) |
379 name_of (if_thm_before canon alias)) |
379 fun add_plains (_, aliases as canon :: _) = fold (add_plain canon) aliases |
380 fun add_plains (_, aliases as canon :: _) = fold (add_plain canon) aliases |
380 fun add_inclass (name, target) = |
381 fun add_inclass (name, target) = |
384 val inclass_name_tab = Symtab.fold add_inclass plain_name_tab Symtab.empty |
385 val inclass_name_tab = Symtab.fold add_inclass plain_name_tab Symtab.empty |
385 in (plain_name_tab, inclass_name_tab) end |
386 in (plain_name_tab, inclass_name_tab) end |
386 |
387 |
387 fun uniquify facts = |
388 fun uniquify facts = |
388 Termtab.fold (cons o snd) |
389 Termtab.fold (cons o snd) |
389 (fold (Termtab.default o `(normalize_eq_etc o prop_of o snd)) facts |
390 (fold (Termtab.default o `(normalize_eq_vars o prop_of o snd)) facts |
390 Termtab.empty) [] |
391 Termtab.empty) [] |
391 |
392 |
392 fun struct_induct_rule_on th = |
393 fun struct_induct_rule_on th = |
393 case Logic.strip_horn (prop_of th) of |
394 case Logic.strip_horn (prop_of th) of |
394 (prems, @{const Trueprop} |
395 (prems, @{const Trueprop} |