153 (preds ~~ inducts)) #>> maps snd) |
153 (preds ~~ inducts)) #>> maps snd) |
154 |> snd |
154 |> snd |
155 end |
155 end |
156 (* @end *) |
156 (* @end *) |
157 |
157 |
158 (* @chunk add_inductive *) |
158 (* @chunk read_specification *) |
159 fun read_specification' vars specs lthy = |
159 fun read_specification' vars specs lthy = |
160 let |
160 let |
161 val specs' = map (fn (a, s) => [(a, [s])]) specs |
161 val specs' = map (fn (a, s) => [(a, [s])]) specs |
162 val ((varst, specst), _) = Specification.read_specification vars specs' lthy |
162 val ((varst, specst), _) = |
|
163 Specification.read_specification vars specs' lthy |
163 val specst' = map (apsnd the_single) specst |
164 val specst' = map (apsnd the_single) specst |
164 in |
165 in |
165 (varst, specst') |
166 (varst, specst') |
166 end |
167 end |
167 |
168 (* @end *) |
|
169 |
|
170 (* @chunk add_inductive *) |
168 fun add_inductive preds params specs lthy = |
171 fun add_inductive preds params specs lthy = |
169 let |
172 let |
170 val (vars, specs') = read_specification' (preds @ params) specs lthy; |
173 val (vars, specs') = read_specification' (preds @ params) specs lthy; |
171 val (preds', params') = chop (length preds) vars; |
174 val (preds', params') = chop (length preds) vars; |
172 val params'' = map fst params' |
175 val params'' = map fst params' |
187 (SpecParse.opt_thm_name ":" -- OuterParse.prop))) [] |
190 (SpecParse.opt_thm_name ":" -- OuterParse.prop))) [] |
188 (* @end *) |
191 (* @end *) |
189 |
192 |
190 (* @chunk syntax *) |
193 (* @chunk syntax *) |
191 val ind_decl = |
194 val ind_decl = |
192 parser >> |
195 spec_parser >> |
193 (fn (((loc, preds), params), specs) => |
196 (fn (((loc, preds), params), specs) => |
194 Toplevel.local_theory loc (add_inductive preds params specs)) |
197 Toplevel.local_theory loc (add_inductive preds params specs)) |
195 |
198 |
196 val _ = OuterSyntax.command "simple_inductive" "define inductive predicates" |
199 val _ = OuterSyntax.command "simple_inductive" "define inductive predicates" |
197 OuterKeyword.thy_decl ind_decl |
200 OuterKeyword.thy_decl ind_decl |