author | haftmann |
Tue, 09 Mar 2010 15:47:16 +0100 | |
changeset 35674 | e69013c25b74 |
parent 35648 | 4b01ddafc8a9 |
child 35675 | 189b4a932cfe |
permissions | -rw-r--r-- |
35648 | 1 |
(* Author: Amine Chaieb, University of Cambridge, 2009 |
2 |
Jeremy Avigad, Carnegie Mellon University |
|
3 |
Florian Haftmann, TU Muenchen |
|
4 |
||
5 |
Simple transfer principle on theorems. |
|
31706 | 6 |
*) |
7 |
||
32557
3cfe4c13aa6e
plain structure name; signature constraint; shorter lines
haftmann
parents:
32476
diff
changeset
|
8 |
signature TRANSFER = |
31706 | 9 |
sig |
35648 | 10 |
datatype selection = Direction of term * term | Hints of string list | Prop |
35674 | 11 |
val transfer: Context.generic -> selection -> string list -> thm -> thm list |
31706 | 12 |
type entry |
35648 | 13 |
val add: entry * entry -> thm -> Context.generic -> Context.generic |
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
14 |
val del: thm -> Context.generic -> Context.generic |
31706 | 15 |
val setup: theory -> theory |
16 |
end; |
|
17 |
||
32557
3cfe4c13aa6e
plain structure name; signature constraint; shorter lines
haftmann
parents:
32476
diff
changeset
|
18 |
structure Transfer : TRANSFER = |
31706 | 19 |
struct |
32557
3cfe4c13aa6e
plain structure name; signature constraint; shorter lines
haftmann
parents:
32476
diff
changeset
|
20 |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
21 |
(* data administration *) |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
22 |
|
35647 | 23 |
val direction_of = Thm.dest_binop o Thm.dest_arg o cprop_of; |
24 |
||
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
25 |
fun check_morphism_key ctxt key = |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
26 |
let |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
27 |
val _ = (Thm.match o pairself Thm.cprop_of) (@{thm transfer_morphismI}, key) |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
28 |
handle Pattern.MATCH => error |
35647 | 29 |
("Transfer: expected theorem of the form " ^ quote (Display.string_of_thm ctxt @{thm transfer_morphismI})); |
30 |
in direction_of key end; |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
31 |
|
35674 | 32 |
type entry = { inj : thm list, embed : thm list, return : thm list, cong : thm list, |
33321 | 33 |
guess : bool, hints : string list }; |
34 |
||
35674 | 35 |
fun merge_entry ({ inj = inj1, embed = embed1, return = return1, cong = cong1, guess = guess1, hints = hints1 } : entry, |
36 |
{ inj = inj2, embed = embed2, return = return2, cong = cong2, guess = guess2, hints = hints2 } : entry) = |
|
37 |
{ inj = merge Thm.eq_thm (inj1, inj2), embed = merge Thm.eq_thm (embed1, embed2), |
|
38 |
return = merge Thm.eq_thm (return1, return2), cong = merge Thm.eq_thm (cong1, cong2), |
|
33321 | 39 |
guess = guess1 andalso guess2, hints = merge (op =) (hints1, hints2) }; |
40 |
||
33519 | 41 |
structure Data = Generic_Data |
31706 | 42 |
( |
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
43 |
type T = (thm * entry) list; |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
44 |
val empty = []; |
35647 | 45 |
val extend = I; |
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
46 |
val merge = AList.join Thm.eq_thm (K merge_entry); |
31706 | 47 |
); |
48 |
||
35647 | 49 |
|
50 |
(* data lookup *) |
|
51 |
||
52 |
fun get_by_direction context (a, D) = |
|
53 |
let |
|
54 |
val ctxt = Context.proof_of context; |
|
55 |
val certify = Thm.cterm_of (Context.theory_of context); |
|
56 |
val a0 = certify a; |
|
57 |
val D0 = certify D; |
|
58 |
fun eq_direction ((a, D), thm') = |
|
59 |
let |
|
60 |
val (a', D') = direction_of thm'; |
|
35674 | 61 |
in a aconvc a' andalso D aconvc D' end; |
62 |
in case AList.lookup eq_direction (Data.get context) (a0, D0) of |
|
35647 | 63 |
SOME e => ((a0, D0), e) |
64 |
| NONE => error ("Transfer: no such instance: (" |
|
65 |
^ Syntax.string_of_term ctxt a ^ ", " ^ Syntax.string_of_term ctxt D ^ ")") |
|
66 |
end; |
|
31706 | 67 |
|
35647 | 68 |
fun get_by_hints context hints = |
69 |
let |
|
70 |
val insts = map_filter (fn (k, e) => if exists (member (op =) (#hints e)) hints |
|
71 |
then SOME (direction_of k, e) else NONE) (Data.get context); |
|
72 |
val _ = if null insts then error ("Transfer: no such labels: " ^ commas (map quote hints)) else (); |
|
73 |
in insts end; |
|
74 |
||
75 |
fun splits P [] = [] |
|
76 |
| splits P (xs as (x :: _)) = |
|
77 |
let |
|
78 |
val (pss, qss) = List.partition (P x) xs; |
|
79 |
in if null pss then [qss] else if null qss then [pss] else pss :: splits P qss end; |
|
31706 | 80 |
|
35647 | 81 |
fun get_by_prop context t = |
82 |
let |
|
83 |
val tys = map snd (Term.add_vars t []); |
|
84 |
val _ = if null tys then error "Transfer: unable to guess instance" else (); |
|
85 |
val tyss = splits (curry Type.could_unify) tys; |
|
86 |
val get_ty = typ_of o ctyp_of_term o fst o direction_of; |
|
87 |
val insts = map_filter (fn tys => get_first (fn (k, ss) => |
|
88 |
if Type.could_unify (hd tys, range_type (get_ty k)) |
|
89 |
then SOME (direction_of k, ss) |
|
90 |
else NONE) (Data.get context)) tyss; |
|
91 |
val _ = if null insts then |
|
92 |
error "Transfer: no instances, provide direction or hints explicitly" else (); |
|
93 |
in insts end; |
|
31706 | 94 |
|
95 |
||
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
96 |
(* applying transfer data *) |
31706 | 97 |
|
35674 | 98 |
fun transfer_thm inj_only a0 D0 { inj, embed, return, cong, guess = _, hints = _ } |
35647 | 99 |
leave ctxt0 th = |
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
100 |
let |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
101 |
val ([a, D], ctxt) = apfst (map Drule.dest_term o snd) |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
102 |
(Variable.import true (map Drule.mk_term [a0, D0]) ctxt0); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
103 |
val (aT, bT) = |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
104 |
let val T = typ_of (ctyp_of_term a) |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
105 |
in (Term.range_type T, Term.domain_type T) end; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
106 |
val ctxt' = (Variable.declare_term (term_of a) o Variable.declare_term (term_of D) |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
107 |
o Variable.declare_thm th) ctxt; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
108 |
val ns = filter (fn i => Type.could_unify (snd i, aT) andalso |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
109 |
not (member (op =) leave (fst (fst i)))) (Term.add_vars (prop_of th) []); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
110 |
val (ins, ctxt'') = Variable.variant_fixes (map (fst o fst) ns) ctxt'; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
111 |
val certify = Thm.cterm_of (ProofContext.theory_of ctxt''); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
112 |
val cns = map (certify o Var) ns; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
113 |
val cfis = map (certify o (fn n => Free (n, bT))) ins; |
35648 | 114 |
val cis = map (Thm.capply a) cfis; |
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
115 |
val (hs, ctxt''') = Assumption.add_assumes (map (fn ct => |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
116 |
Thm.capply @{cterm "Trueprop"} (Thm.capply D ct)) cfis) ctxt''; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
117 |
val th1 = Drule.cterm_instantiate (cns ~~ cis) th; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
118 |
val th2 = fold Thm.elim_implies hs (fold_rev implies_intr (map cprop_of hs) th1); |
35647 | 119 |
val simpset = (Simplifier.context ctxt''' HOL_ss) |
35674 | 120 |
addsimps inj addsimps (if inj_only then [] else embed @ return) addcongs cong; |
35647 | 121 |
val th3 = Simplifier.asm_full_simplify simpset |
122 |
(fold_rev implies_intr (map cprop_of hs) th2); |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
123 |
in hd (Variable.export ctxt''' ctxt0 [th3]) end; |
31706 | 124 |
|
35647 | 125 |
fun transfer_thm_multiple inj_only insts leave ctxt thm = |
35674 | 126 |
map (fn ((a, D), e) => transfer_thm false a D e leave ctxt thm) insts; |
31706 | 127 |
|
35648 | 128 |
datatype selection = Direction of term * term | Hints of string list | Prop; |
35647 | 129 |
|
35648 | 130 |
fun insts_for context thm (Direction direction) = [get_by_direction context direction] |
131 |
| insts_for context thm (Hints hints) = get_by_hints context hints |
|
132 |
| insts_for context thm Prop = get_by_prop context (Thm.prop_of thm); |
|
31706 | 133 |
|
35648 | 134 |
fun transfer context selection leave thm = |
135 |
transfer_thm_multiple false (insts_for context thm selection) leave (Context.proof_of context) thm; |
|
31706 | 136 |
|
137 |
||
35647 | 138 |
(* maintaining transfer data *) |
31706 | 139 |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
140 |
fun merge_update eq m (k, v) [] = [(k, v)] |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
141 |
| merge_update eq m (k, v) ((k', v') :: al) = |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
142 |
if eq (k, k') then (k', m (v, v')) :: al else (k', v') :: merge_update eq m (k, v) al; |
32813 | 143 |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
144 |
(*? fun merge_update eq m (k, v) = AList.map_entry eq k (fn v' => m (v, v'));*) |
32813 | 145 |
|
35674 | 146 |
fun merge_entries {inj = inj0, embed = embed0, return = return0, cong = cong0, guess = guess0, hints = hints0} |
147 |
({inj = inj1, embed = embed1, return = return1, cong = cong1, guess = guess1, hints = hints1}, |
|
148 |
{inj = inj2, embed = embed2, return = return2, cong = cong2, guess = guess2, hints = hints2} : entry) = |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
149 |
let |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
150 |
fun h xs0 xs ys = subtract Thm.eq_thm xs0 (merge Thm.eq_thm (xs, ys)) |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
151 |
in |
35674 | 152 |
{inj = h inj0 inj1 inj2, embed = h embed0 embed1 embed2, |
153 |
return = h return0 return1 return2, cong = h cong0 cong1 cong2, guess = guess1 andalso guess2, |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
154 |
hints = subtract (op =) hints0 (union (op =) hints1 hints2) } |
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
155 |
end; |
31706 | 156 |
|
35674 | 157 |
fun add (e0 as {inj = inja, embed = embeda, return = returna, cong = conga, guess = guess, hints = hintsa}, |
158 |
ed as {inj = injd, embed = embedd, return = returnd, cong = congd, guess = _, hints = hintsd}) key context = |
|
35648 | 159 |
context |
160 |
|> Data.map (fn al => |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
161 |
let |
35648 | 162 |
val ctxt = Context.proof_of context; |
163 |
val (a0, D0) = check_morphism_key ctxt key; |
|
35674 | 164 |
val entry = if guess then |
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
165 |
let |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
166 |
val inj' = if null inja then #inj |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
167 |
(case AList.lookup Thm.eq_thm al key of SOME e => e |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
168 |
| NONE => error "Transfer: cannot generate return rules on the fly, either add injectivity axiom or force manual mode with mode: manual") |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
169 |
else inja |
35674 | 170 |
val return' = merge Thm.eq_thm (returna, map |
171 |
(fn th => transfer_thm true a0 D0 {inj = inj', embed = [], return = [], cong = conga, |
|
172 |
guess = guess, hints = hintsa} [] ctxt th RS sym) embeda); |
|
173 |
in {inj = inja, embed = embeda, return = return', cong = conga, guess = guess, hints = hintsa} end |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
174 |
else e0; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
175 |
in merge_update Thm.eq_thm (merge_entries ed) (key, entry) al end); |
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
176 |
|
35647 | 177 |
fun del key = Data.map (remove (eq_fst Thm.eq_thm) (key, [])); |
178 |
||
31706 | 179 |
|
35638
50655e2ebc85
dropped dead code; adhere more closely to standard coding conventions
haftmann
parents:
33519
diff
changeset
|
180 |
(* syntax *) |
31706 | 181 |
|
182 |
local |
|
183 |
||
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
184 |
fun these scan = Scan.optional scan []; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
185 |
fun these_pair scan = Scan.optional scan ([], []); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
186 |
|
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
187 |
fun keyword k = Scan.lift (Args.$$$ k) >> K (); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
188 |
fun keyword_colon k = Scan.lift (Args.$$$ k -- Args.colon) >> K (); |
31706 | 189 |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
190 |
val addN = "add"; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
191 |
val delN = "del"; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
192 |
val modeN = "mode"; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
193 |
val automaticN = "automatic"; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
194 |
val manualN = "manual"; |
35674 | 195 |
val injN = "inj"; |
196 |
val embedN = "embed"; |
|
197 |
val returnN = "return"; |
|
198 |
val congN = "cong"; |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
199 |
val labelsN = "labels"; |
31706 | 200 |
|
35674 | 201 |
val leavingN = "leaving"; |
202 |
val directionN = "direction"; |
|
203 |
||
204 |
val any_keyword = keyword_colon addN || keyword_colon delN || keyword_colon modeN |
|
205 |
|| keyword_colon injN || keyword_colon embedN || keyword_colon returnN |
|
206 |
|| keyword_colon congN || keyword_colon labelsN |
|
207 |
|| keyword_colon leavingN || keyword_colon directionN; |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
208 |
|
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
209 |
val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat; |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
210 |
val names = Scan.repeat (Scan.unless any_keyword (Scan.lift Args.name)) |
31706 | 211 |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
212 |
val mode = keyword_colon modeN |-- ((Scan.lift (Args.$$$ manualN) >> K false) |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
213 |
|| (Scan.lift (Args.$$$ automaticN) >> K true)); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
214 |
val inj = (keyword_colon injN |-- thms) -- these (keyword_colon delN |-- thms); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
215 |
val embed = (keyword_colon embedN |-- thms) -- these (keyword_colon delN |-- thms); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
216 |
val return = (keyword_colon returnN |-- thms) -- these (keyword_colon delN |-- thms); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
217 |
val cong = (keyword_colon congN |-- thms) -- these (keyword_colon delN |-- thms); |
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
218 |
val labels = (keyword_colon labelsN |-- names) -- these (keyword_colon delN |-- names); |
31706 | 219 |
|
35648 | 220 |
val entry_pair = Scan.optional mode true -- these_pair inj -- these_pair embed |
221 |
-- these_pair return -- these_pair cong -- these_pair labels |
|
35674 | 222 |
>> (fn (((((g, (inja, injd)), (embeda, embedd)), (returna, returnd)), (conga, congd)), |
223 |
(hintsa, hintsd)) => |
|
224 |
({inj = inja, embed = embeda, return = returna, cong = conga, guess = g, hints = hintsa}, |
|
225 |
{inj = injd, embed = embedd, return = returnd, cong = congd, guess = g, hints = hintsd})); |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
226 |
|
35648 | 227 |
val selection = (keyword_colon directionN |-- (Args.term -- Args.term) >> Direction) |
228 |
|| these names >> (fn hints => if null hints then Prop else Hints hints); |
|
35645
74e4542d0a4a
transfer: avoid camel case, more standard coding conventions, misc tuning
haftmann
parents:
35638
diff
changeset
|
229 |
|
31706 | 230 |
in |
231 |
||
35648 | 232 |
val transfer_attribute = Scan.lift (Args.$$$ delN >> K (Thm.declaration_attribute del)) |
233 |
|| Scan.unless any_keyword (keyword addN) |-- entry_pair |
|
234 |
>> (fn entry_pair => Thm.declaration_attribute (add entry_pair)) |
|
31706 | 235 |
|
35648 | 236 |
val transferred_attribute = selection -- these (keyword_colon leavingN |-- names) |
35674 | 237 |
>> (fn (selection, leave) => Thm.rule_attribute (fn context => |
238 |
Conjunction.intr_balanced o transfer context selection leave)); |
|
31706 | 239 |
|
240 |
end; |
|
241 |
||
242 |
||
243 |
(* theory setup *) |
|
244 |
||
245 |
val setup = |
|
35648 | 246 |
Attrib.setup @{binding transfer} transfer_attribute |
31706 | 247 |
"Installs transfer data" #> |
35648 | 248 |
Attrib.setup @{binding transferred} transferred_attribute |
31706 | 249 |
"Transfers theorems"; |
250 |
||
251 |
end; |