349 function. |
349 function. |
350 |
350 |
351 \end{description} |
351 \end{description} |
352 *} |
352 *} |
353 |
353 |
354 text %mlex {* The following toy examples illustrate how the goal facts |
354 text %mlex {* See also @{command method_setup} in |
|
355 \cite{isabelle-isar-ref} which includes some abstract examples. |
|
356 |
|
357 \medskip The following toy examples illustrate how the goal facts |
355 and state are passed to proof methods. The pre-defined proof method |
358 and state are passed to proof methods. The pre-defined proof method |
356 called ``@{method tactic}'' wraps ML source of type @{ML_type |
359 called ``@{method tactic}'' wraps ML source of type @{ML_type |
357 tactic} (abstracted over @{verbatim facts}). This allows immediate |
360 tactic} (abstracted over @{verbatim facts}). This allows immediate |
358 experimentation without parsing of concrete syntax. *} |
361 experimentation without parsing of concrete syntax. *} |
359 |
362 |
404 this: |
407 this: |
405 *} |
408 *} |
406 |
409 |
407 example_proof |
410 example_proof |
408 fix a b c |
411 fix a b c |
409 assume a: "a \<equiv> b" |
412 assume a: "a = b" |
410 assume b: "b \<equiv> c" |
413 assume b: "b = c" |
411 have "a \<equiv> c" by (my_simp a b) |
414 have "a = c" by (my_simp a b) |
|
415 qed |
|
416 |
|
417 text {* Here is a similar method that operates on all subgoals, |
|
418 instead of just the first one. *} |
|
419 |
|
420 method_setup my_simp_all = {* |
|
421 Attrib.thms >> (fn thms => fn ctxt => |
|
422 SIMPLE_METHOD |
|
423 (CHANGED |
|
424 (ALLGOALS (asm_full_simp_tac |
|
425 (HOL_basic_ss addsimps thms))))) |
|
426 *} "rewrite all subgoals by given rules" |
|
427 |
|
428 example_proof |
|
429 fix a b c |
|
430 assume a: "a = b" |
|
431 assume b: "b = c" |
|
432 have "a = c" and "c = b" by (my_simp_all a b) |
|
433 |
412 qed |
434 qed |
413 |
435 |
414 text {* \medskip Apart from explicit arguments, common proof methods |
436 text {* \medskip Apart from explicit arguments, common proof methods |
415 typically work with a default configuration provided by the context. |
437 typically work with a default configuration provided by the context. |
416 As a shortcut to rule management we use a cheap solution via functor |
438 As a shortcut to rule management we use a cheap solution via functor |
448 assume [my_simp]: "a \<equiv> b" |
470 assume [my_simp]: "a \<equiv> b" |
449 assume [my_simp]: "b \<equiv> c" |
471 assume [my_simp]: "b \<equiv> c" |
450 have "a \<equiv> c" by my_simp' |
472 have "a \<equiv> c" by my_simp' |
451 qed |
473 qed |
452 |
474 |
453 text {* \medskip Both @{method my_simp} and @{method my_simp'} are |
475 text {* \medskip The @{method my_simp} variants defined above are |
454 simple methods, i.e.\ the goal facts are merely inserted as goal |
476 ``simple'' methods, i.e.\ the goal facts are merely inserted as goal |
455 premises by the @{ML SIMPLE_METHOD'} wrapper. For proof methods |
477 premises by the @{ML SIMPLE_METHOD'} or @{ML SIMPLE_METHOD} wrapper. |
456 that are similar to the standard collection of @{method simp}, |
478 For proof methods that are similar to the standard collection of |
457 @{method blast}, @{method auto} little more can be done here. |
479 @{method simp}, @{method blast}, @{method auto} little more can be |
|
480 done here. |
458 |
481 |
459 Note that using the primary goal facts in the same manner as the |
482 Note that using the primary goal facts in the same manner as the |
460 method arguments obtained via concrete syntax or the context does |
483 method arguments obtained via concrete syntax or the context does |
461 not meet the requirement of ``strong emphasis on facts'' of regular |
484 not meet the requirement of ``strong emphasis on facts'' of regular |
462 proof methods, because rewrite rules as used above can be easily |
485 proof methods, because rewrite rules as used above can be easily |