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