76 in |
76 in |
77 ("copy_def", %%:(dname^"_copy") == /\ "f" |
77 ("copy_def", %%:(dname^"_copy") == /\ "f" |
78 (dc_abs oo (copy_of_dtyp map_tab r (dtyp_of_eq eqn)) oo dc_rep)) |
78 (dc_abs oo (copy_of_dtyp map_tab r (dtyp_of_eq eqn)) oo dc_rep)) |
79 end; |
79 end; |
80 |
80 |
81 (* -- definitions concerning the constructors, discriminators and selectors - *) |
81 (* -- definitions concerning the discriminators and selectors - *) |
82 |
82 |
83 fun con_def m n (_,args) = let |
|
84 fun idxs z x arg = (if is_lazy arg then mk_up else I) (Bound(z-x)); |
|
85 fun parms vs = mk_stuple (mapn (idxs(length vs)) 1 vs); |
|
86 fun inj y 1 _ = y |
|
87 | inj y _ 0 = mk_sinl y |
|
88 | inj y i j = mk_sinr (inj y (i-1) (j-1)); |
|
89 in List.foldr /\# (dc_abs`(inj (parms args) m n)) args end; |
|
90 |
|
91 val con_defs = mapn (fn n => fn (con, _, args) => |
|
92 (extern_name con ^"_def", %%:con == con_def (length cons) n (con,args))) 0 cons; |
|
93 |
|
94 val dis_defs = let |
83 val dis_defs = let |
95 fun ddef (con,_,_) = (dis_name con ^"_def",%%:(dis_name con) == |
84 fun ddef (con,_,_) = (dis_name con ^"_def",%%:(dis_name con) == |
96 list_ccomb(%%:(dname^"_when"),map |
85 list_ccomb(%%:(dname^"_when"),map |
97 (fn (con',_,args) => (List.foldr /\# |
86 (fn (con',_,args) => (List.foldr /\# |
98 (if con'=con then TT else FF) args)) cons)) |
87 (if con'=con then TT else FF) args)) cons)) |
150 mk_ex("n",(%%:(dname^"_take") $ Bound 0)`Bound 1 === Bound 1))); |
139 mk_ex("n",(%%:(dname^"_take") $ Bound 0)`Bound 1 === Bound 1))); |
151 |
140 |
152 in (dnam, |
141 in (dnam, |
153 (if definitional then [] else [abs_iso_ax, rep_iso_ax, reach_ax]), |
142 (if definitional then [] else [abs_iso_ax, rep_iso_ax, reach_ax]), |
154 (if definitional then [when_def] else [when_def, copy_def]) @ |
143 (if definitional then [when_def] else [when_def, copy_def]) @ |
155 con_defs @ dis_defs @ mat_defs @ pat_defs @ sel_defs @ |
144 dis_defs @ mat_defs @ pat_defs @ sel_defs @ |
156 [take_def, finite_def]) |
145 [take_def, finite_def]) |
157 end; (* let (calc_axioms) *) |
146 end; (* let (calc_axioms) *) |
158 |
147 |
159 |
148 |
160 (* legacy type inference *) |
149 (* legacy type inference *) |
224 mk_all (x_name(n+1), |
213 mk_all (x_name(n+1), |
225 mk_all (x_name(n+1)^"'", |
214 mk_all (x_name(n+1)^"'", |
226 mk_imp (proj (Bound 2) eqs n $ Bound 1 $ Bound 0, |
215 mk_imp (proj (Bound 2) eqs n $ Bound 1 $ Bound 0, |
227 foldr1 mk_disj (mk_conj(Bound 1 === UU,Bound 0 === UU) |
216 foldr1 mk_disj (mk_conj(Bound 1 === UU,Bound 0 === UU) |
228 ::map one_con cons)))); |
217 ::map one_con cons)))); |
|
218 (* TEMPORARILY DISABLED |
229 val bisim_def = |
219 val bisim_def = |
230 ("bisim_def", %%:(comp_dname^"_bisim") == |
220 ("bisim_def", %%:(comp_dname^"_bisim") == |
231 mk_lam("R", foldr1 mk_conj (mapn one_comp 0 eqs))); |
221 mk_lam("R", foldr1 mk_conj (mapn one_comp 0 eqs))); |
|
222 TEMPORARILY DISABLED *) |
232 |
223 |
233 fun add_one (dnam, axs, dfs) = |
224 fun add_one (dnam, axs, dfs) = |
234 Sign.add_path dnam |
225 Sign.add_path dnam |
235 #> add_defs_infer dfs |
226 #> add_defs_infer dfs |
236 #> add_axioms_infer axs |
227 #> add_axioms_infer axs |
243 |
234 |
244 val use_copy_def = length eqs>1 andalso not definitional; |
235 val use_copy_def = length eqs>1 andalso not definitional; |
245 in |
236 in |
246 thy |
237 thy |
247 |> Sign.add_path comp_dnam |
238 |> Sign.add_path comp_dnam |
248 |> add_defs_infer (bisim_def::(if use_copy_def then [copy_def] else [])) |
239 |> add_defs_infer ((*bisim_def::*)(if use_copy_def then [copy_def] else [])) |
249 |> Sign.parent_path |
240 |> Sign.parent_path |
250 |> fold add_matchers eqs |
241 |> fold add_matchers eqs |
251 end; (* let (add_axioms) *) |
242 end; (* let (add_axioms) *) |
252 |
243 |
253 end; (* struct *) |
244 end; (* struct *) |