6954
|
1 |
(* Title: Pure/Isar/local_defs.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Muenchen
|
8807
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
6954
|
5 |
|
|
6 |
Local definitions.
|
|
7 |
*)
|
|
8 |
|
|
9 |
signature LOCAL_DEFS =
|
|
10 |
sig
|
|
11 |
val def: string -> Proof.context attribute list
|
|
12 |
-> (string * string option) * (string * string list) -> Proof.state -> Proof.state
|
|
13 |
val def_i: string -> Proof.context attribute list
|
7667
|
14 |
-> (string * typ option) * (term * term list) -> Proof.state -> Proof.state
|
6954
|
15 |
end;
|
|
16 |
|
|
17 |
structure LocalDefs: LOCAL_DEFS =
|
|
18 |
struct
|
|
19 |
|
7502
|
20 |
val refl_tac = Tactic.rtac (Drule.standard (Drule.reflexive_thm RS Drule.triv_goal));
|
6954
|
21 |
|
8092
|
22 |
fun gen_def fix prep_term prep_pats raw_name atts ((x, raw_T), (raw_rhs, raw_pats)) state =
|
6954
|
23 |
let
|
9295
|
24 |
val _ = Proof.assert_forward state;
|
6954
|
25 |
|
9295
|
26 |
(*rhs*)
|
|
27 |
val ctxt = Proof.context_of state;
|
7416
|
28 |
val name = if raw_name = "" then Thm.def_name x else raw_name;
|
9295
|
29 |
val rhs = prep_term ctxt raw_rhs;
|
6954
|
30 |
val T = Term.fastype_of rhs;
|
9295
|
31 |
val pats = prep_pats T (ProofContext.declare_term rhs ctxt) raw_pats;
|
|
32 |
|
|
33 |
(*lhs*)
|
|
34 |
val state' = fix [([x], raw_T)] state;
|
|
35 |
val lhs = ProofContext.intern_skolem (Proof.context_of state') (Free (x, T));
|
6954
|
36 |
in
|
|
37 |
state'
|
8092
|
38 |
|> Proof.match_bind_i [(pats, rhs)]
|
9295
|
39 |
|> Proof.assm_i (refl_tac, refl_tac) [(name, atts, [(Logic.mk_equals (lhs, rhs), ([], []))])]
|
6954
|
40 |
end;
|
|
41 |
|
8092
|
42 |
val def = gen_def Proof.fix ProofContext.read_term ProofContext.read_term_pats;
|
|
43 |
val def_i = gen_def Proof.fix_i ProofContext.cert_term ProofContext.cert_term_pats;
|
6954
|
44 |
|
|
45 |
|
|
46 |
end;
|