158 Seq.single (Drule.compose_single(complete_thm, i, thm)) |
159 Seq.single (Drule.compose_single(complete_thm, i, thm)) |
159 end |
160 end |
160 handle COMPLETENESS => Seq.empty |
161 handle COMPLETENESS => Seq.empty |
161 |
162 |
162 |
163 |
|
164 val pat_completeness = Method.SIMPLE_METHOD (pat_complete_tac 1) |
|
165 |
|
166 val by_pat_completeness_simp = |
|
167 Proof.global_terminal_proof |
|
168 (Method.Basic (K pat_completeness), |
|
169 SOME (Method.Source (Args.src (("simp_all", []), Position.none)))) |
|
170 |
163 |
171 |
164 val setup = |
172 val setup = |
165 Method.add_methods [("pat_completeness", Method.no_args (Method.SIMPLE_METHOD (pat_complete_tac 1)), "Completeness prover for datatype patterns")] |
173 Method.add_methods [("pat_completeness", Method.no_args pat_completeness, "Completeness prover for datatype patterns")] |
166 |
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 local structure P = OuterParse and K = OuterKeyword in |
|
181 |
|
182 |
|
183 fun local_theory_to_proof f = |
|
184 Toplevel.theory_to_proof (f o LocalTheory.init NONE) |
|
185 |
|
186 fun or_list1 s = P.enum1 "|" s |
|
187 val otherwise = P.$$$ "(" |-- P.$$$ "otherwise" --| P.$$$ ")" |
|
188 val statement_ow = P.and_list1 (P.opt_thm_name ":" -- Scan.repeat1 (P.prop -- Scan.optional (otherwise >> K true) false)) |
|
189 val statements_ow = or_list1 statement_ow |
|
190 |
|
191 val funP = |
|
192 OuterSyntax.command "fun" "define general recursive functions (short version)" K.thy_decl |
|
193 ((P.opt_locale_target -- P.fixes --| P.$$$ "where" -- statements_ow) |
|
194 >> (fn ((target, fixes), statements) => |
|
195 Toplevel.print o Toplevel.local_theory NONE (FundefPackage.add_fundef fixes statements true |
|
196 #> by_pat_completeness_simp))); |
|
197 |
|
198 val _ = OuterSyntax.add_parsers [funP]; |
167 end |
199 end |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 end |