blob: 85ce66992ef279ea885fa8203abbce5f5dc542b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
(* Title: elimination.ML
Author: Joshua Chen
Type elimination automation.
*)
structure Elim = struct
(* Elimination rule data *)
structure Rules = Generic_Data (
type T = thm Termtab.table
val empty = Termtab.empty
val extend = I
val merge = Termtab.merge Thm.eq_thm_prop
)
fun register_rule rl =
let val hd = Term.head_of (Lib.type_of_typing (Thm.major_prem_of rl))
in Rules.map (Termtab.update (hd, rl)) end
fun get_rule ctxt = Termtab.lookup (Rules.get (Context.Proof ctxt))
fun rules ctxt = map (op #2) (Termtab.dest (Rules.get (Context.Proof ctxt)))
(* Set up [elims] attribute *)
val _ = Theory.setup (
Attrib.setup \<^binding>\<open>elims\<close>
(Scan.lift (Scan.succeed (Thm.declaration_attribute register_rule))) ""
#> Global_Theory.add_thms_dynamic (\<^binding>\<open>elims\<close>,
fn context => (rules (Context.proof_of context)))
)
end
|