99 $ rec_tm)) |
99 $ rec_tm)) |
100 in map mk_intr constructs end; |
100 in map mk_intr constructs end; |
101 |
101 |
102 fun mk_all_intr_tms sg arg = List.concat (ListPair.map (mk_intr_tms sg) arg); |
102 fun mk_all_intr_tms sg arg = List.concat (ListPair.map (mk_intr_tms sg) arg); |
103 |
103 |
104 val Un = Const("op Un", [iT,iT]--->iT) |
104 fun mk_Un (t1, t2) = Const("op Un", [iT,iT]--->iT) $ t1 $ t2; |
105 and empty = Const("0", iT) |
105 |
|
106 val empty = Const("0", iT) |
106 and univ = Const("Univ.univ", iT-->iT) |
107 and univ = Const("Univ.univ", iT-->iT) |
107 and quniv = Const("QUniv.quniv", iT-->iT); |
108 and quniv = Const("QUniv.quniv", iT-->iT); |
108 |
109 |
109 (*Make a datatype's domain: form the union of its set parameters*) |
110 (*Make a datatype's domain: form the union of its set parameters*) |
110 fun union_params (rec_tm, cs) = |
111 fun union_params (rec_tm, cs) = |
111 let val (_,args) = strip_comb rec_tm |
112 let val (_,args) = strip_comb rec_tm |
112 fun is_ind arg = (type_of arg = iT) |
113 fun is_ind arg = (type_of arg = iT) |
113 in case filter is_ind (args @ cs) of |
114 in case filter is_ind (args @ cs) of |
114 [] => empty |
115 [] => empty |
115 | u_args => fold_bal (app Un) u_args |
116 | u_args => fold_bal mk_Un u_args |
116 end; |
117 end; |
117 |
118 |
118 (*univ or quniv constitutes the sum domain for mutual recursion; |
119 (*univ or quniv constitutes the sum domain for mutual recursion; |
119 it is applied to the datatype parameters and to Consts occurring in the |
120 it is applied to the datatype parameters and to Consts occurring in the |
120 definition other than Nat.nat and the datatype sets themselves. |
121 definition other than Nat.nat and the datatype sets themselves. |
149 val elim_rls = [asm_rl, FalseE, succ_neq_0, sym RS succ_neq_0, |
150 val elim_rls = [asm_rl, FalseE, succ_neq_0, sym RS succ_neq_0, |
150 Pair_neq_0, sym RS Pair_neq_0, Pair_inject, |
151 Pair_neq_0, sym RS Pair_neq_0, Pair_inject, |
151 make_elim succ_inject, |
152 make_elim succ_inject, |
152 refl_thin, conjE, exE, disjE]; |
153 refl_thin, conjE, exE, disjE]; |
153 |
154 |
|
155 |
|
156 (*From HOL/ex/meson.ML: raises exception if no rules apply -- unlike RL*) |
|
157 fun tryres (th, rl::rls) = (th RS rl handle THM _ => tryres(th,rls)) |
|
158 | tryres (th, []) = raise THM("tryres", 0, [th]); |
|
159 |
|
160 fun gen_make_elim elim_rls rl = |
|
161 standard (tryres (rl, elim_rls @ [revcut_rl])); |
|
162 |
154 (*Turns iff rules into safe elimination rules*) |
163 (*Turns iff rules into safe elimination rules*) |
155 fun mk_free_SEs iffs = map (gen_make_elim [conjE,FalseE]) (iffs RL [iffD1]); |
164 fun mk_free_SEs iffs = map (gen_make_elim [conjE,FalseE]) (iffs RL [iffD1]); |
|
165 |
156 |
166 |
157 end; |
167 end; |
158 |
168 |
159 |
169 |
160 (*For convenient access by the user*) |
170 (*For convenient access by the user*) |