author | huffman |
Thu, 19 Nov 2009 22:25:11 -0800 | |
changeset 33809 | 033831fd9ef3 |
parent 33807 | ce8d2e8bca21 |
child 33845 | 91f3fc0364cf |
permissions | -rw-r--r-- |
33774 | 1 |
(* Title: HOLCF/Tools/domain/domain_isomorphism.ML |
2 |
Author: Brian Huffman |
|
3 |
||
4 |
Defines new types satisfying the given domain equations. |
|
5 |
*) |
|
6 |
||
7 |
signature DOMAIN_ISOMORPHISM = |
|
8 |
sig |
|
9 |
val domain_isomorphism: |
|
33791 | 10 |
(string list * binding * mixfix * typ) list -> theory -> theory |
33774 | 11 |
val domain_isomorphism_cmd: |
33791 | 12 |
(string list * binding * mixfix * string) list -> theory -> theory |
13 |
val add_type_constructor: |
|
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
14 |
(string * term * string * thm * thm * thm) -> theory -> theory |
33801 | 15 |
val get_map_tab: |
16 |
theory -> string Symtab.table |
|
33774 | 17 |
end; |
18 |
||
19 |
structure Domain_Isomorphism :> DOMAIN_ISOMORPHISM = |
|
20 |
struct |
|
21 |
||
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
22 |
val beta_ss = |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
23 |
HOL_basic_ss |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
24 |
addsimps simp_thms |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
25 |
addsimps [@{thm beta_cfun}] |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
26 |
addsimprocs [@{simproc cont_proc}]; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
27 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
28 |
val beta_tac = simp_tac beta_ss; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
29 |
|
33774 | 30 |
(******************************************************************************) |
33791 | 31 |
(******************************** theory data *********************************) |
32 |
(******************************************************************************) |
|
33 |
||
34 |
structure DeflData = Theory_Data |
|
35 |
( |
|
36 |
type T = term Symtab.table; |
|
37 |
val empty = Symtab.empty; |
|
38 |
val extend = I; |
|
39 |
fun merge data = Symtab.merge (K true) data; |
|
40 |
); |
|
41 |
||
42 |
structure MapData = Theory_Data |
|
43 |
( |
|
44 |
type T = string Symtab.table; |
|
45 |
val empty = Symtab.empty; |
|
46 |
val extend = I; |
|
47 |
fun merge data = Symtab.merge (K true) data; |
|
48 |
); |
|
49 |
||
50 |
structure RepData = Theory_Data |
|
51 |
( |
|
52 |
type T = thm list; |
|
53 |
val empty = []; |
|
54 |
val extend = I; |
|
55 |
val merge = Thm.merge_thms; |
|
56 |
); |
|
57 |
||
58 |
structure IsodeflData = Theory_Data |
|
59 |
( |
|
60 |
type T = thm list; |
|
61 |
val empty = []; |
|
62 |
val extend = I; |
|
63 |
val merge = Thm.merge_thms; |
|
64 |
); |
|
65 |
||
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
66 |
structure MapIdData = Theory_Data |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
67 |
( |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
68 |
type T = thm list; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
69 |
val empty = []; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
70 |
val extend = I; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
71 |
val merge = Thm.merge_thms; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
72 |
); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
73 |
|
33791 | 74 |
fun add_type_constructor |
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
75 |
(tname, defl_const, map_name, REP_thm, isodefl_thm, map_ID_thm) = |
33791 | 76 |
DeflData.map (Symtab.insert (K true) (tname, defl_const)) |
77 |
#> MapData.map (Symtab.insert (K true) (tname, map_name)) |
|
78 |
#> RepData.map (Thm.add_thm REP_thm) |
|
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
79 |
#> IsodeflData.map (Thm.add_thm isodefl_thm) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
80 |
#> MapIdData.map (Thm.add_thm map_ID_thm); |
33791 | 81 |
|
33801 | 82 |
val get_map_tab = MapData.get; |
83 |
||
33791 | 84 |
|
85 |
(******************************************************************************) |
|
33774 | 86 |
(******************************* building types *******************************) |
87 |
(******************************************************************************) |
|
88 |
||
89 |
(* ->> is taken from holcf_logic.ML *) |
|
90 |
fun cfunT (T, U) = Type(@{type_name "->"}, [T, U]); |
|
91 |
||
92 |
infixr 6 ->>; val (op ->>) = cfunT; |
|
93 |
||
94 |
fun dest_cfunT (Type(@{type_name "->"}, [T, U])) = (T, U) |
|
95 |
| dest_cfunT T = raise TYPE ("dest_cfunT", [T], []); |
|
96 |
||
97 |
fun tupleT [] = HOLogic.unitT |
|
98 |
| tupleT [T] = T |
|
99 |
| tupleT (T :: Ts) = HOLogic.mk_prodT (T, tupleT Ts); |
|
100 |
||
101 |
val deflT = @{typ "udom alg_defl"}; |
|
102 |
||
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
103 |
fun mapT (T as Type (_, Ts)) = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
104 |
Library.foldr cfunT (map (fn T => T ->> T) Ts, T ->> T); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
105 |
|
33774 | 106 |
(******************************************************************************) |
107 |
(******************************* building terms *******************************) |
|
108 |
(******************************************************************************) |
|
109 |
||
110 |
(* builds the expression (v1,v2,..,vn) *) |
|
111 |
fun mk_tuple [] = HOLogic.unit |
|
112 |
| mk_tuple (t::[]) = t |
|
113 |
| mk_tuple (t::ts) = HOLogic.mk_prod (t, mk_tuple ts); |
|
114 |
||
115 |
(* builds the expression (%(v1,v2,..,vn). rhs) *) |
|
116 |
fun lambda_tuple [] rhs = Term.lambda (Free("unit", HOLogic.unitT)) rhs |
|
117 |
| lambda_tuple (v::[]) rhs = Term.lambda v rhs |
|
118 |
| lambda_tuple (v::vs) rhs = |
|
119 |
HOLogic.mk_split (Term.lambda v (lambda_tuple vs rhs)); |
|
120 |
||
121 |
(* continuous application and abstraction *) |
|
122 |
||
123 |
fun capply_const (S, T) = |
|
124 |
Const(@{const_name Rep_CFun}, (S ->> T) --> (S --> T)); |
|
125 |
||
126 |
fun cabs_const (S, T) = |
|
127 |
Const(@{const_name Abs_CFun}, (S --> T) --> (S ->> T)); |
|
128 |
||
129 |
fun mk_cabs t = |
|
130 |
let val T = Term.fastype_of t |
|
131 |
in cabs_const (Term.domain_type T, Term.range_type T) $ t end |
|
132 |
||
133 |
(* builds the expression (LAM v. rhs) *) |
|
134 |
fun big_lambda v rhs = |
|
135 |
cabs_const (Term.fastype_of v, Term.fastype_of rhs) $ Term.lambda v rhs; |
|
136 |
||
137 |
(* builds the expression (LAM v1 v2 .. vn. rhs) *) |
|
138 |
fun big_lambdas [] rhs = rhs |
|
139 |
| big_lambdas (v::vs) rhs = big_lambda v (big_lambdas vs rhs); |
|
140 |
||
141 |
fun mk_capply (t, u) = |
|
142 |
let val (S, T) = |
|
143 |
case Term.fastype_of t of |
|
144 |
Type(@{type_name "->"}, [S, T]) => (S, T) |
|
145 |
| _ => raise TERM ("mk_capply " ^ ML_Syntax.print_list ML_Syntax.print_term [t, u], [t, u]); |
|
146 |
in capply_const (S, T) $ t $ u end; |
|
147 |
||
148 |
(* miscellaneous term constructions *) |
|
149 |
||
150 |
val mk_trp = HOLogic.mk_Trueprop; |
|
151 |
||
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
152 |
val mk_fst = HOLogic.mk_fst; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
153 |
val mk_snd = HOLogic.mk_snd; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
154 |
|
33774 | 155 |
fun mk_cont t = |
156 |
let val T = Term.fastype_of t |
|
157 |
in Const(@{const_name cont}, T --> HOLogic.boolT) $ t end; |
|
158 |
||
159 |
fun mk_fix t = |
|
160 |
let val (T, _) = dest_cfunT (Term.fastype_of t) |
|
161 |
in mk_capply (Const(@{const_name fix}, (T ->> T) ->> T), t) end; |
|
162 |
||
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
163 |
fun ID_const T = Const (@{const_name ID}, cfunT (T, T)); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
164 |
|
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
165 |
fun cfcomp_const (T, U, V) = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
166 |
Const (@{const_name cfcomp}, (U ->> V) ->> (T ->> U) ->> (T ->> V)); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
167 |
|
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
168 |
fun mk_cfcomp (f, g) = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
169 |
let |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
170 |
val (U, V) = dest_cfunT (Term.fastype_of f); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
171 |
val (T, U') = dest_cfunT (Term.fastype_of g); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
172 |
in |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
173 |
if U = U' |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
174 |
then mk_capply (mk_capply (cfcomp_const (T, U, V), f), g) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
175 |
else raise TYPE ("mk_cfcomp", [U, U'], [f, g]) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
176 |
end; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
177 |
|
33774 | 178 |
fun mk_Rep_of T = |
179 |
Const (@{const_name Rep_of}, Term.itselfT T --> deflT) $ Logic.mk_type T; |
|
180 |
||
33778 | 181 |
fun coerce_const T = Const (@{const_name coerce}, T); |
182 |
||
33788 | 183 |
fun isodefl_const T = |
184 |
Const (@{const_name isodefl}, (T ->> T) --> deflT --> HOLogic.boolT); |
|
185 |
||
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
186 |
(* splits a cterm into the right and lefthand sides of equality *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
187 |
fun dest_eqs t = HOLogic.dest_eq (HOLogic.dest_Trueprop t); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
188 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
189 |
fun mk_eqs (t, u) = HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
190 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
191 |
(******************************************************************************) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
192 |
(*************** fixed-point definitions and unfolding theorems ***************) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
193 |
(******************************************************************************) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
194 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
195 |
fun add_fixdefs |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
196 |
(spec : (binding * term) list) |
33788 | 197 |
(thy : theory) : (thm list * thm list) * theory = |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
198 |
let |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
199 |
val binds = map fst spec; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
200 |
val (lhss, rhss) = ListPair.unzip (map (dest_eqs o snd) spec); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
201 |
val functional = lambda_tuple lhss (mk_tuple rhss); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
202 |
val fixpoint = mk_fix (mk_cabs functional); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
203 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
204 |
(* project components of fixpoint *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
205 |
fun mk_projs (x::[]) t = [(x, t)] |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
206 |
| mk_projs (x::xs) t = (x, mk_fst t) :: mk_projs xs (mk_snd t); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
207 |
val projs = mk_projs lhss fixpoint; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
208 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
209 |
(* convert parameters to lambda abstractions *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
210 |
fun mk_eqn (lhs, rhs) = |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
211 |
case lhs of |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
212 |
Const (@{const_name Rep_CFun}, _) $ f $ (x as Free _) => |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
213 |
mk_eqn (f, big_lambda x rhs) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
214 |
| Const _ => Logic.mk_equals (lhs, rhs) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
215 |
| _ => raise TERM ("lhs not of correct form", [lhs, rhs]); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
216 |
val eqns = map mk_eqn projs; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
217 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
218 |
(* register constant definitions *) |
33777 | 219 |
val (fixdef_thms, thy) = |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
220 |
(PureThy.add_defs false o map Thm.no_attributes) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
221 |
(map (Binding.suffix_name "_def") binds ~~ eqns) thy; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
222 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
223 |
(* prove applied version of definitions *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
224 |
fun prove_proj (lhs, rhs) = |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
225 |
let |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
226 |
val tac = rewrite_goals_tac fixdef_thms THEN beta_tac 1; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
227 |
val goal = Logic.mk_equals (lhs, rhs); |
33777 | 228 |
in Goal.prove_global thy [] [] goal (K tac) end; |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
229 |
val proj_thms = map prove_proj projs; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
230 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
231 |
(* mk_tuple lhss == fixpoint *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
232 |
fun pair_equalI (thm1, thm2) = @{thm Pair_equalI} OF [thm1, thm2]; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
233 |
val tuple_fixdef_thm = foldr1 pair_equalI proj_thms; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
234 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
235 |
val cont_thm = |
33777 | 236 |
Goal.prove_global thy [] [] (mk_trp (mk_cont functional)) |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
237 |
(K (beta_tac 1)); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
238 |
val tuple_unfold_thm = |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
239 |
(@{thm def_cont_fix_eq} OF [tuple_fixdef_thm, cont_thm]) |
33777 | 240 |
|> LocalDefs.unfold (ProofContext.init thy) @{thms split_conv}; |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
241 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
242 |
fun mk_unfold_thms [] thm = [] |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
243 |
| mk_unfold_thms (n::[]) thm = [(n, thm)] |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
244 |
| mk_unfold_thms (n::ns) thm = let |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
245 |
val thmL = thm RS @{thm Pair_eqD1}; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
246 |
val thmR = thm RS @{thm Pair_eqD2}; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
247 |
in (n, thmL) :: mk_unfold_thms ns thmR end; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
248 |
val unfold_binds = map (Binding.suffix_name "_unfold") binds; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
249 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
250 |
(* register unfold theorems *) |
33777 | 251 |
val (unfold_thms, thy) = |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
252 |
(PureThy.add_thms o map (Thm.no_attributes o apsnd Drule.standard)) |
33777 | 253 |
(mk_unfold_thms unfold_binds tuple_unfold_thm) thy; |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
254 |
in |
33788 | 255 |
((proj_thms, unfold_thms), thy) |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
256 |
end; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
257 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
258 |
|
33774 | 259 |
(******************************************************************************) |
33790 | 260 |
(****************** deflation combinators and map functions *******************) |
261 |
(******************************************************************************) |
|
33774 | 262 |
|
263 |
fun defl_of_typ |
|
264 |
(tab : term Symtab.table) |
|
265 |
(T : typ) : term = |
|
266 |
let |
|
267 |
fun is_closed_typ (Type (_, Ts)) = forall is_closed_typ Ts |
|
268 |
| is_closed_typ _ = false; |
|
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
269 |
fun defl_of (TFree (a, _)) = Free (Library.unprefix "'" a, deflT) |
33774 | 270 |
| defl_of (TVar _) = error ("defl_of_typ: TVar") |
271 |
| defl_of (T as Type (c, Ts)) = |
|
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
272 |
case Symtab.lookup tab c of |
33774 | 273 |
SOME t => Library.foldl mk_capply (t, map defl_of Ts) |
274 |
| NONE => if is_closed_typ T |
|
275 |
then mk_Rep_of T |
|
276 |
else error ("defl_of_typ: type variable under unsupported type constructor " ^ c); |
|
277 |
in defl_of T end; |
|
278 |
||
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
279 |
fun map_of_typ |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
280 |
(tab : string Symtab.table) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
281 |
(T : typ) : term = |
33774 | 282 |
let |
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
283 |
fun is_closed_typ (Type (_, Ts)) = forall is_closed_typ Ts |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
284 |
| is_closed_typ _ = false; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
285 |
fun map_of (T as TFree (a, _)) = Free (Library.unprefix "'" a, T ->> T) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
286 |
| map_of (T as TVar _) = error ("map_of_typ: TVar") |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
287 |
| map_of (T as Type (c, Ts)) = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
288 |
case Symtab.lookup tab c of |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
289 |
SOME t => Library.foldl mk_capply (Const (t, mapT T), map map_of Ts) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
290 |
| NONE => if is_closed_typ T |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
291 |
then ID_const T |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
292 |
else error ("map_of_typ: type variable under unsupported type constructor " ^ c); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
293 |
in map_of T end; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
294 |
|
33774 | 295 |
|
296 |
(******************************************************************************) |
|
297 |
(* prepare datatype specifications *) |
|
298 |
||
299 |
fun read_typ thy str sorts = |
|
300 |
let |
|
301 |
val ctxt = ProofContext.init thy |
|
302 |
|> fold (Variable.declare_typ o TFree) sorts; |
|
303 |
val T = Syntax.read_typ ctxt str; |
|
304 |
in (T, Term.add_tfreesT T sorts) end; |
|
305 |
||
306 |
fun cert_typ sign raw_T sorts = |
|
307 |
let |
|
308 |
val T = Type.no_tvars (Sign.certify_typ sign raw_T) |
|
309 |
handle TYPE (msg, _, _) => error msg; |
|
310 |
val sorts' = Term.add_tfreesT T sorts; |
|
311 |
val _ = |
|
312 |
case duplicates (op =) (map fst sorts') of |
|
313 |
[] => () |
|
314 |
| dups => error ("Inconsistent sort constraints for " ^ commas dups) |
|
315 |
in (T, sorts') end; |
|
316 |
||
317 |
fun gen_domain_isomorphism |
|
318 |
(prep_typ: theory -> 'a -> (string * sort) list -> typ * (string * sort) list) |
|
319 |
(doms_raw: (string list * binding * mixfix * 'a) list) |
|
320 |
(thy: theory) |
|
321 |
: theory = |
|
322 |
let |
|
33792 | 323 |
val _ = Theory.requires thy "Representable" "domain isomorphisms"; |
33774 | 324 |
|
325 |
(* this theory is used just for parsing *) |
|
326 |
val tmp_thy = thy |> |
|
327 |
Theory.copy |> |
|
328 |
Sign.add_types (map (fn (tvs, tname, mx, _) => |
|
329 |
(tname, length tvs, mx)) doms_raw); |
|
330 |
||
331 |
fun prep_dom thy (vs, t, mx, typ_raw) sorts = |
|
332 |
let val (typ, sorts') = prep_typ thy typ_raw sorts |
|
333 |
in ((vs, t, mx, typ), sorts') end; |
|
334 |
||
335 |
val (doms : (string list * binding * mixfix * typ) list, |
|
336 |
sorts : (string * sort) list) = |
|
337 |
fold_map (prep_dom tmp_thy) doms_raw []; |
|
338 |
||
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
339 |
(* domain equations *) |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
340 |
fun mk_dom_eqn (vs, tbind, mx, rhs) = |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
341 |
let fun arg v = TFree (v, the (AList.lookup (op =) sorts v)); |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
342 |
in (Type (Sign.full_name tmp_thy tbind, map arg vs), rhs) end; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
343 |
val dom_eqns = map mk_dom_eqn doms; |
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
344 |
|
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
345 |
(* check for valid type parameters *) |
33774 | 346 |
val (tyvars, _, _, _)::_ = doms; |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
347 |
val new_doms = map (fn (tvs, tname, mx, _) => |
33774 | 348 |
let val full_tname = Sign.full_name tmp_thy tname |
349 |
in |
|
350 |
(case duplicates (op =) tvs of |
|
351 |
[] => |
|
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
352 |
if eq_set (op =) (tyvars, tvs) then (full_tname, tvs) |
33774 | 353 |
else error ("Mutually recursive domains must have same type parameters") |
354 |
| dups => error ("Duplicate parameter(s) for domain " ^ quote (Binding.str_of tname) ^ |
|
355 |
" : " ^ commas dups)) |
|
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
356 |
end) doms; |
33782 | 357 |
val dom_binds = map (fn (_, tbind, _, _) => tbind) doms; |
33774 | 358 |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
359 |
(* declare deflation combinator constants *) |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
360 |
fun declare_defl_const (vs, tbind, mx, rhs) thy = |
33774 | 361 |
let |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
362 |
val defl_type = Library.foldr cfunT (map (K deflT) vs, deflT); |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
363 |
val defl_bind = Binding.suffix_name "_defl" tbind; |
33774 | 364 |
in |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
365 |
Sign.declare_const ((defl_bind, defl_type), NoSyn) thy |
33774 | 366 |
end; |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
367 |
val (defl_consts, thy) = fold_map declare_defl_const doms thy; |
33774 | 368 |
|
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
369 |
(* defining equations for type combinators *) |
33790 | 370 |
val defl_tab1 = DeflData.get thy; |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
371 |
val defl_tab2 = |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
372 |
Symtab.make (map (fst o dest_Type o fst) dom_eqns ~~ defl_consts); |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
373 |
val defl_tab' = Symtab.merge (K true) (defl_tab1, defl_tab2); |
33790 | 374 |
val thy = DeflData.put defl_tab' thy; |
33776 | 375 |
fun mk_defl_spec (lhsT, rhsT) = |
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
376 |
mk_eqs (defl_of_typ defl_tab' lhsT, |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
377 |
defl_of_typ defl_tab' rhsT); |
33775
7a1518c42c56
cleaned up; factored out fixed-point definition code
huffman
parents:
33774
diff
changeset
|
378 |
val defl_specs = map mk_defl_spec dom_eqns; |
33774 | 379 |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
380 |
(* register recursive definition of deflation combinators *) |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
381 |
val defl_binds = map (Binding.suffix_name "_defl") dom_binds; |
33788 | 382 |
val ((defl_apply_thms, defl_unfold_thms), thy) = |
383 |
add_fixdefs (defl_binds ~~ defl_specs) thy; |
|
33774 | 384 |
|
33776 | 385 |
(* define types using deflation combinators *) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
386 |
fun make_repdef ((vs, tbind, mx, _), defl_const) thy = |
33774 | 387 |
let |
388 |
fun tfree a = TFree (a, the (AList.lookup (op =) sorts a)) |
|
389 |
val reps = map (mk_Rep_of o tfree) vs; |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
390 |
val defl = Library.foldl mk_capply (defl_const, reps); |
33777 | 391 |
val ((_, _, _, {REP, ...}), thy) = |
33774 | 392 |
Repdef.add_repdef false NONE (tbind, vs, mx) defl NONE thy; |
393 |
in |
|
33777 | 394 |
(REP, thy) |
33774 | 395 |
end; |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
396 |
val (REP_thms, thy) = fold_map make_repdef (doms ~~ defl_consts) thy; |
33791 | 397 |
val thy = RepData.map (fold Thm.add_thm REP_thms) thy; |
33776 | 398 |
|
399 |
(* prove REP equations *) |
|
33782 | 400 |
fun mk_REP_eq_thm (lhsT, rhsT) = |
33776 | 401 |
let |
402 |
val goal = mk_eqs (mk_Rep_of lhsT, mk_Rep_of rhsT); |
|
33791 | 403 |
val REP_simps = RepData.get thy; |
33776 | 404 |
val tac = |
405 |
simp_tac (HOL_basic_ss addsimps REP_simps) 1 |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33782
diff
changeset
|
406 |
THEN resolve_tac defl_unfold_thms 1; |
33776 | 407 |
in |
33777 | 408 |
Goal.prove_global thy [] [] goal (K tac) |
33776 | 409 |
end; |
33782 | 410 |
val REP_eq_thms = map mk_REP_eq_thm dom_eqns; |
411 |
||
412 |
(* register REP equations *) |
|
413 |
val REP_eq_binds = map (Binding.prefix_name "REP_eq_") dom_binds; |
|
414 |
val (_, thy) = thy |> |
|
415 |
(PureThy.add_thms o map Thm.no_attributes) |
|
416 |
(REP_eq_binds ~~ REP_eq_thms); |
|
33776 | 417 |
|
33778 | 418 |
(* define rep/abs functions *) |
33782 | 419 |
fun mk_rep_abs (tbind, (lhsT, rhsT)) thy = |
33778 | 420 |
let |
421 |
val rep_type = cfunT (lhsT, rhsT); |
|
33782 | 422 |
val abs_type = cfunT (rhsT, lhsT); |
33778 | 423 |
val rep_bind = Binding.suffix_name "_rep" tbind; |
424 |
val abs_bind = Binding.suffix_name "_abs" tbind; |
|
425 |
val (rep_const, thy) = thy |> |
|
426 |
Sign.declare_const ((rep_bind, rep_type), NoSyn); |
|
427 |
val (abs_const, thy) = thy |> |
|
428 |
Sign.declare_const ((abs_bind, abs_type), NoSyn); |
|
429 |
val rep_eqn = Logic.mk_equals (rep_const, coerce_const rep_type); |
|
430 |
val abs_eqn = Logic.mk_equals (abs_const, coerce_const abs_type); |
|
431 |
val ([rep_def, abs_def], thy) = thy |> |
|
432 |
(PureThy.add_defs false o map Thm.no_attributes) |
|
433 |
[(Binding.suffix_name "_rep_def" tbind, rep_eqn), |
|
434 |
(Binding.suffix_name "_abs_def" tbind, abs_eqn)]; |
|
435 |
in |
|
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
436 |
(((rep_const, abs_const), (rep_def, abs_def)), thy) |
33778 | 437 |
end; |
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
438 |
val ((rep_abs_consts, rep_abs_defs), thy) = thy |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
439 |
|> fold_map mk_rep_abs (dom_binds ~~ dom_eqns) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
440 |
|>> ListPair.unzip; |
33782 | 441 |
|
442 |
(* prove isomorphism and isodefl rules *) |
|
443 |
fun mk_iso_thms ((tbind, REP_eq), (rep_def, abs_def)) thy = |
|
444 |
let |
|
445 |
fun make thm = Drule.standard (thm OF [REP_eq, abs_def, rep_def]); |
|
446 |
val rep_iso_thm = make @{thm domain_rep_iso}; |
|
447 |
val abs_iso_thm = make @{thm domain_abs_iso}; |
|
448 |
val isodefl_thm = make @{thm isodefl_abs_rep}; |
|
33797 | 449 |
val rep_iso_bind = Binding.name "rep_iso"; |
450 |
val abs_iso_bind = Binding.name "abs_iso"; |
|
451 |
val isodefl_bind = Binding.name "isodefl_abs_rep"; |
|
452 |
val (_, thy) = thy |
|
453 |
|> Sign.add_path (Binding.name_of tbind) |
|
454 |
|> (PureThy.add_thms o map Thm.no_attributes) |
|
455 |
[(rep_iso_bind, rep_iso_thm), |
|
456 |
(abs_iso_bind, abs_iso_thm), |
|
457 |
(isodefl_bind, isodefl_thm)] |
|
458 |
||> Sign.parent_path; |
|
33782 | 459 |
in |
460 |
(((rep_iso_thm, abs_iso_thm), isodefl_thm), thy) |
|
461 |
end; |
|
462 |
val ((iso_thms, isodefl_abs_rep_thms), thy) = thy |
|
463 |
|> fold_map mk_iso_thms (dom_binds ~~ REP_eq_thms ~~ rep_abs_defs) |
|
464 |
|>> ListPair.unzip; |
|
33778 | 465 |
|
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
466 |
(* declare map functions *) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
467 |
fun declare_map_const (tbind, (lhsT, rhsT)) thy = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
468 |
let |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
469 |
val map_type = mapT lhsT; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
470 |
val map_bind = Binding.suffix_name "_map" tbind; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
471 |
in |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
472 |
Sign.declare_const ((map_bind, map_type), NoSyn) thy |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
473 |
end; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
474 |
val (map_consts, thy) = thy |> |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
475 |
fold_map declare_map_const (dom_binds ~~ dom_eqns); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
476 |
|
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
477 |
(* defining equations for map functions *) |
33790 | 478 |
val map_tab1 = MapData.get thy; |
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
479 |
val map_tab2 = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
480 |
Symtab.make (map (fst o dest_Type o fst) dom_eqns |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
481 |
~~ map (fst o dest_Const) map_consts); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
482 |
val map_tab' = Symtab.merge (K true) (map_tab1, map_tab2); |
33790 | 483 |
val thy = MapData.put map_tab' thy; |
33785
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
484 |
fun mk_map_spec ((rep_const, abs_const), (lhsT, rhsT)) = |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
485 |
let |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
486 |
val lhs = map_of_typ map_tab' lhsT; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
487 |
val body = map_of_typ map_tab' rhsT; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
488 |
val rhs = mk_cfcomp (abs_const, mk_cfcomp (body, rep_const)); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
489 |
in mk_eqs (lhs, rhs) end; |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
490 |
val map_specs = map mk_map_spec (rep_abs_consts ~~ dom_eqns); |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
491 |
|
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
492 |
(* register recursive definition of map functions *) |
2f2d9eb37084
automate definition of map functions; remove unused code
huffman
parents:
33784
diff
changeset
|
493 |
val map_binds = map (Binding.suffix_name "_map") dom_binds; |
33788 | 494 |
val ((map_apply_thms, map_unfold_thms), thy) = |
495 |
add_fixdefs (map_binds ~~ map_specs) thy; |
|
496 |
||
497 |
(* prove isodefl rules for map functions *) |
|
498 |
val isodefl_thm = |
|
499 |
let |
|
500 |
fun unprime a = Library.unprefix "'" a; |
|
501 |
fun mk_d (TFree (a, _)) = Free ("d" ^ unprime a, deflT); |
|
502 |
fun mk_f (T as TFree (a, _)) = Free ("f" ^ unprime a, T ->> T); |
|
503 |
fun mk_assm T = mk_trp (isodefl_const T $ mk_f T $ mk_d T); |
|
504 |
fun mk_goal ((map_const, defl_const), (T as Type (c, Ts), rhsT)) = |
|
505 |
let |
|
506 |
val map_term = Library.foldl mk_capply (map_const, map mk_f Ts); |
|
507 |
val defl_term = Library.foldl mk_capply (defl_const, map mk_d Ts); |
|
508 |
in isodefl_const T $ map_term $ defl_term end; |
|
509 |
val assms = (map mk_assm o snd o dest_Type o fst o hd) dom_eqns; |
|
510 |
val goals = map mk_goal (map_consts ~~ defl_consts ~~ dom_eqns); |
|
511 |
val goal = mk_trp (foldr1 HOLogic.mk_conj goals); |
|
512 |
val start_thms = |
|
513 |
@{thm split_def} :: defl_apply_thms @ map_apply_thms; |
|
514 |
val adm_rules = |
|
515 |
@{thms adm_conj adm_isodefl cont2cont_fst cont2cont_snd cont_id}; |
|
516 |
val bottom_rules = |
|
517 |
@{thms fst_strict snd_strict isodefl_bottom simp_thms}; |
|
518 |
val isodefl_rules = |
|
33791 | 519 |
@{thms conjI isodefl_ID_REP} |
520 |
@ isodefl_abs_rep_thms |
|
521 |
@ IsodeflData.get thy; |
|
33788 | 522 |
fun tacf {prems, ...} = EVERY |
523 |
[simp_tac (HOL_basic_ss addsimps start_thms) 1, |
|
33791 | 524 |
(* FIXME: how reliable is unification here? *) |
525 |
(* Maybe I should instantiate the rule. *) |
|
33788 | 526 |
rtac @{thm parallel_fix_ind} 1, |
527 |
REPEAT (resolve_tac adm_rules 1), |
|
528 |
simp_tac (HOL_basic_ss addsimps bottom_rules) 1, |
|
529 |
simp_tac beta_ss 1, |
|
530 |
simp_tac (HOL_basic_ss addsimps @{thms fst_conv snd_conv}) 1, |
|
531 |
REPEAT (etac @{thm conjE} 1), |
|
532 |
REPEAT (resolve_tac (isodefl_rules @ prems) 1 ORELSE atac 1)]; |
|
533 |
in |
|
534 |
Goal.prove_global thy [] assms goal tacf |
|
535 |
end; |
|
33789 | 536 |
val isodefl_binds = map (Binding.prefix_name "isodefl_") dom_binds; |
537 |
fun conjuncts [] thm = [] |
|
538 |
| conjuncts (n::[]) thm = [(n, thm)] |
|
539 |
| conjuncts (n::ns) thm = let |
|
540 |
val thmL = thm RS @{thm conjunct1}; |
|
541 |
val thmR = thm RS @{thm conjunct2}; |
|
542 |
in (n, thmL):: conjuncts ns thmR end; |
|
543 |
val (isodefl_thms, thy) = thy |> |
|
544 |
(PureThy.add_thms o map (Thm.no_attributes o apsnd Drule.standard)) |
|
545 |
(conjuncts isodefl_binds isodefl_thm); |
|
33791 | 546 |
val thy = IsodeflData.map (fold Thm.add_thm isodefl_thms) thy; |
33793 | 547 |
|
548 |
(* prove map_ID theorems *) |
|
549 |
fun prove_map_ID_thm |
|
550 |
(((map_const, (lhsT, _)), REP_thm), isodefl_thm) = |
|
551 |
let |
|
552 |
val Ts = snd (dest_Type lhsT); |
|
553 |
val lhs = Library.foldl mk_capply (map_const, map ID_const Ts); |
|
554 |
val goal = mk_eqs (lhs, ID_const lhsT); |
|
555 |
val tac = EVERY |
|
556 |
[rtac @{thm isodefl_REP_imp_ID} 1, |
|
557 |
stac REP_thm 1, |
|
558 |
rtac isodefl_thm 1, |
|
559 |
REPEAT (rtac @{thm isodefl_ID_REP} 1)]; |
|
560 |
in |
|
561 |
Goal.prove_global thy [] [] goal (K tac) |
|
562 |
end; |
|
563 |
val map_ID_binds = map (Binding.suffix_name "_map_ID") dom_binds; |
|
564 |
val map_ID_thms = |
|
565 |
map prove_map_ID_thm |
|
566 |
(map_consts ~~ dom_eqns ~~ REP_thms ~~ isodefl_thms); |
|
567 |
val (_, thy) = thy |> |
|
568 |
(PureThy.add_thms o map Thm.no_attributes) |
|
569 |
(map_ID_binds ~~ map_ID_thms); |
|
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
570 |
val thy = MapIdData.map (fold Thm.add_thm map_ID_thms) thy; |
33802
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
571 |
|
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
572 |
(* define copy combinators *) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
573 |
val new_dts = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
574 |
map (apsnd (map (fst o dest_TFree)) o dest_Type o fst) dom_eqns; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
575 |
val copy_arg_type = tupleT (map (fn (T, _) => T ->> T) dom_eqns); |
33807
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
576 |
val copy_arg = Free ("f", copy_arg_type); |
33802
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
577 |
val copy_args = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
578 |
let fun mk_copy_args [] t = [] |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
579 |
| mk_copy_args (_::[]) t = [t] |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
580 |
| mk_copy_args (_::xs) t = |
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
581 |
mk_fst t :: mk_copy_args xs (mk_snd t); |
33807
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
582 |
in mk_copy_args doms copy_arg end; |
33802
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
583 |
fun copy_of_dtyp (T, dt) = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
584 |
if DatatypeAux.is_rec_type dt |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
585 |
then copy_of_dtyp' (T, dt) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
586 |
else ID_const T |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
587 |
and copy_of_dtyp' (T, DatatypeAux.DtRec i) = nth copy_args i |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
588 |
| copy_of_dtyp' (T, DatatypeAux.DtTFree a) = ID_const T |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
589 |
| copy_of_dtyp' (T as Type (_, Ts), DatatypeAux.DtType (c, ds)) = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
590 |
case Symtab.lookup map_tab' c of |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
591 |
SOME f => |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
592 |
Library.foldl mk_capply |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
593 |
(Const (f, mapT T), map copy_of_dtyp (Ts ~~ ds)) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
594 |
| NONE => |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
595 |
(warning ("copy_of_dtyp: unknown type constructor " ^ c); ID_const T); |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
596 |
fun define_copy ((tbind, (rep_const, abs_const)), (lhsT, rhsT)) thy = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
597 |
let |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
598 |
val copy_type = copy_arg_type ->> (lhsT ->> lhsT); |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
599 |
val copy_bind = Binding.suffix_name "_copy" tbind; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
600 |
val (copy_const, thy) = thy |> |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
601 |
Sign.declare_const ((copy_bind, copy_type), NoSyn); |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
602 |
val dtyp = DatatypeAux.dtyp_of_typ new_dts rhsT; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
603 |
val body = copy_of_dtyp (rhsT, dtyp); |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
604 |
val comp = mk_cfcomp (abs_const, mk_cfcomp (body, rep_const)); |
33807
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
605 |
val rhs = big_lambda copy_arg comp; |
33802
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
606 |
val eqn = Logic.mk_equals (copy_const, rhs); |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
607 |
val ([copy_def], thy) = |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
608 |
thy |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
609 |
|> Sign.add_path (Binding.name_of tbind) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
610 |
|> (PureThy.add_defs false o map Thm.no_attributes) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
611 |
[(Binding.name "copy_def", eqn)] |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
612 |
||> Sign.parent_path; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
613 |
in ((copy_const, copy_def), thy) end; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
614 |
val ((copy_consts, copy_defs), thy) = thy |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
615 |
|> fold_map define_copy (dom_binds ~~ rep_abs_consts ~~ dom_eqns) |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
616 |
|>> ListPair.unzip; |
48ce3a1063f2
domain_isomorphism package defines copy functions
huffman
parents:
33801
diff
changeset
|
617 |
|
33807
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
618 |
(* define combined copy combinator *) |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
619 |
val ((c_const, c_def_thms), thy) = |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
620 |
if length doms = 1 |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
621 |
then ((hd copy_consts, []), thy) |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
622 |
else |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
623 |
let |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
624 |
val c_type = copy_arg_type ->> copy_arg_type; |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
625 |
val c_name = space_implode "_" (map Binding.name_of dom_binds); |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
626 |
val c_bind = Binding.name (c_name ^ "_copy"); |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
627 |
val c_body = |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
628 |
mk_tuple (map (mk_capply o rpair copy_arg) copy_consts); |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
629 |
val c_rhs = big_lambda copy_arg c_body; |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
630 |
val (c_const, thy) = |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
631 |
Sign.declare_const ((c_bind, c_type), NoSyn) thy; |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
632 |
val c_eqn = Logic.mk_equals (c_const, c_rhs); |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
633 |
val (c_def_thms, thy) = |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
634 |
thy |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
635 |
|> Sign.add_path c_name |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
636 |
|> (PureThy.add_defs false o map Thm.no_attributes) |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
637 |
[(Binding.name "copy_def", c_eqn)] |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
638 |
||> Sign.parent_path; |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
639 |
in ((c_const, c_def_thms), thy) end; |
ce8d2e8bca21
domain_isomorphism package defines combined copy function
huffman
parents:
33802
diff
changeset
|
640 |
|
33809
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
641 |
(* fixed-point lemma for combined copy combinator *) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
642 |
val fix_copy_lemma = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
643 |
let |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
644 |
fun mk_map_ID (map_const, (Type (c, Ts), rhsT)) = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
645 |
Library.foldl mk_capply (map_const, map ID_const Ts); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
646 |
val rhs = mk_tuple (map mk_map_ID (map_consts ~~ dom_eqns)); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
647 |
val goal = mk_eqs (mk_fix c_const, rhs); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
648 |
val rules = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
649 |
[@{thm pair_collapse}, @{thm split_def}] |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
650 |
@ map_apply_thms |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
651 |
@ c_def_thms @ copy_defs |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
652 |
@ MapIdData.get thy; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
653 |
val tac = simp_tac (beta_ss addsimps rules) 1; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
654 |
in |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
655 |
Goal.prove_global thy [] [] goal (K tac) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
656 |
end; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
657 |
|
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
658 |
(* prove reach lemmas *) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
659 |
val reach_thm_projs = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
660 |
let fun mk_projs (x::[]) t = [(x, t)] |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
661 |
| mk_projs (x::xs) t = (x, mk_fst t) :: mk_projs xs (mk_snd t); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
662 |
in mk_projs dom_binds (mk_fix c_const) end; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
663 |
fun prove_reach_thm (((bind, t), map_ID_thm), (lhsT, rhsT)) thy = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
664 |
let |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
665 |
val x = Free ("x", lhsT); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
666 |
val goal = mk_eqs (mk_capply (t, x), x); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
667 |
val rules = |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
668 |
fix_copy_lemma :: map_ID_thm :: @{thms fst_conv snd_conv ID1}; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
669 |
val tac = simp_tac (HOL_basic_ss addsimps rules) 1; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
670 |
val reach_thm = Goal.prove_global thy [] [] goal (K tac); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
671 |
in |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
672 |
thy |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
673 |
|> Sign.add_path (Binding.name_of bind) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
674 |
|> yield_singleton (PureThy.add_thms o map Thm.no_attributes) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
675 |
(Binding.name "reach", reach_thm) |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
676 |
||> Sign.parent_path |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
677 |
end; |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
678 |
val (reach_thms, thy) = thy |> |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
679 |
fold_map prove_reach_thm (reach_thm_projs ~~ map_ID_thms ~~ dom_eqns); |
033831fd9ef3
store map_ID thms in theory data; automate proofs of reach lemmas
huffman
parents:
33807
diff
changeset
|
680 |
|
33774 | 681 |
in |
33777 | 682 |
thy |
33774 | 683 |
end; |
684 |
||
685 |
val domain_isomorphism = gen_domain_isomorphism cert_typ; |
|
686 |
val domain_isomorphism_cmd = gen_domain_isomorphism read_typ; |
|
687 |
||
688 |
(******************************************************************************) |
|
689 |
(******************************** outer syntax ********************************) |
|
690 |
(******************************************************************************) |
|
691 |
||
692 |
local |
|
693 |
||
694 |
structure P = OuterParse and K = OuterKeyword |
|
695 |
||
696 |
val parse_domain_iso : (string list * binding * mixfix * string) parser = |
|
697 |
(P.type_args -- P.binding -- P.opt_infix -- (P.$$$ "=" |-- P.typ)) |
|
698 |
>> (fn (((vs, t), mx), rhs) => (vs, t, mx, rhs)); |
|
699 |
||
700 |
val parse_domain_isos = P.and_list1 parse_domain_iso; |
|
701 |
||
702 |
in |
|
703 |
||
704 |
val _ = |
|
705 |
OuterSyntax.command "domain_isomorphism" "define domain isomorphisms (HOLCF)" K.thy_decl |
|
706 |
(parse_domain_isos >> (Toplevel.theory o domain_isomorphism_cmd)); |
|
707 |
||
708 |
end; |
|
709 |
||
710 |
end; |