src/Doc/Isar_Ref/Generic.thy
changeset 59905 678c9e625782
parent 59853 4039d8aecda4
child 59917 9830c944670f
equal deleted inserted replaced
59904:9d04e2c188b3 59905:678c9e625782
    16   name.  This form of context declaration works particularly well with
    16   name.  This form of context declaration works particularly well with
    17   commands such as @{command "declare"} or @{command "using"} like
    17   commands such as @{command "declare"} or @{command "using"} like
    18   this:
    18   this:
    19 \<close>
    19 \<close>
    20 
    20 
       
    21 (*<*)experiment begin(*>*)
    21 declare [[show_main_goal = false]]
    22 declare [[show_main_goal = false]]
    22 
    23 
    23 notepad
    24 notepad
    24 begin
    25 begin
    25   note [[show_main_goal = true]]
    26   note [[show_main_goal = true]]
    26 end
    27 end
       
    28 (*<*)end(*>*)
    27 
    29 
    28 text \<open>For historical reasons, some tools cannot take the full proof
    30 text \<open>For historical reasons, some tools cannot take the full proof
    29   context into account and merely refer to the background theory.
    31   context into account and merely refer to the background theory.
    30   This is accommodated by configuration options being declared as
    32   This is accommodated by configuration options being declared as
    31   ``global'', which may not be changed within a local context.
    33   ``global'', which may not be changed within a local context.
   814 
   816 
   815   Ordered rewriting with the combination of A, C, and LC sorts a term
   817   Ordered rewriting with the combination of A, C, and LC sorts a term
   816   lexicographically --- the rewriting engine imitates bubble-sort.
   818   lexicographically --- the rewriting engine imitates bubble-sort.
   817 \<close>
   819 \<close>
   818 
   820 
   819 locale AC_example =
   821 experiment
   820   fixes f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infix "\<bullet>" 60)
   822   fixes f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infix "\<bullet>" 60)
   821   assumes assoc: "(x \<bullet> y) \<bullet> z = x \<bullet> (y \<bullet> z)"
   823   assumes assoc: "(x \<bullet> y) \<bullet> z = x \<bullet> (y \<bullet> z)"
   822   assumes commute: "x \<bullet> y = y \<bullet> x"
   824   assumes commute: "x \<bullet> y = y \<bullet> x"
   823 begin
   825 begin
   824 
   826 
   920   rewrite step. For example:
   922   rewrite step. For example:
   921 
   923 
   922   \end{description}
   924   \end{description}
   923 \<close>
   925 \<close>
   924 
   926 
       
   927 (*<*)experiment begin(*>*)
   925 declare conjI [simp_break]
   928 declare conjI [simp_break]
   926 declare [[simp_break "?x \<and> ?y"]]
   929 declare [[simp_break "?x \<and> ?y"]]
       
   930 (*<*)end(*>*)
   927 
   931 
   928 
   932 
   929 subsection \<open>Simplification procedures \label{sec:simproc}\<close>
   933 subsection \<open>Simplification procedures \label{sec:simproc}\<close>
   930 
   934 
   931 text \<open>Simplification procedures are ML functions that produce proven
   935 text \<open>Simplification procedures are ML functions that produce proven
   994   control over rule application, beyond higher-order pattern matching.
   998   control over rule application, beyond higher-order pattern matching.
   995   Declaring @{thm unit_eq} as @{attribute simp} directly would make
   999   Declaring @{thm unit_eq} as @{attribute simp} directly would make
   996   the Simplifier loop!  Note that a version of this simplification
  1000   the Simplifier loop!  Note that a version of this simplification
   997   procedure is already active in Isabelle/HOL.\<close>
  1001   procedure is already active in Isabelle/HOL.\<close>
   998 
  1002 
       
  1003 (*<*)experiment begin(*>*)
   999 simproc_setup unit ("x::unit") =
  1004 simproc_setup unit ("x::unit") =
  1000   \<open>fn _ => fn _ => fn ct =>
  1005   \<open>fn _ => fn _ => fn ct =>
  1001     if HOLogic.is_unit (Thm.term_of ct) then NONE
  1006     if HOLogic.is_unit (Thm.term_of ct) then NONE
  1002     else SOME (mk_meta_eq @{thm unit_eq})\<close>
  1007     else SOME (mk_meta_eq @{thm unit_eq})\<close>
       
  1008 (*<*)end(*>*)
  1003 
  1009 
  1004 text \<open>Since the Simplifier applies simplification procedures
  1010 text \<open>Since the Simplifier applies simplification procedures
  1005   frequently, it is important to make the failure check in ML
  1011   frequently, it is important to make the failure check in ML
  1006   reasonably fast.\<close>
  1012   reasonably fast.\<close>
  1007 
  1013 
  1047   \end{description}
  1053   \end{description}
  1048 
  1054 
  1049   As an example, consider the following alternative subgoaler:
  1055   As an example, consider the following alternative subgoaler:
  1050 \<close>
  1056 \<close>
  1051 
  1057 
  1052 ML \<open>
  1058 ML_val \<open>
  1053   fun subgoaler_tac ctxt =
  1059   fun subgoaler_tac ctxt =
  1054     assume_tac ctxt ORELSE'
  1060     assume_tac ctxt ORELSE'
  1055     resolve_tac ctxt (Simplifier.prems_of ctxt) ORELSE'
  1061     resolve_tac ctxt (Simplifier.prems_of ctxt) ORELSE'
  1056     asm_simp_tac ctxt
  1062     asm_simp_tac ctxt
  1057 \<close>
  1063 \<close>
  1871   All members of a wrapper list are applied in turn to the respective
  1877   All members of a wrapper list are applied in turn to the respective
  1872   step tactic.
  1878   step tactic.
  1873 
  1879 
  1874   Initially the two wrapper lists are empty, which means no
  1880   Initially the two wrapper lists are empty, which means no
  1875   modification of the step tactics. Safe and unsafe wrappers are added
  1881   modification of the step tactics. Safe and unsafe wrappers are added
  1876   to a claset with the functions given below, supplying them with
  1882   to the context with the functions given below, supplying them with
  1877   wrapper names.  These names may be used to selectively delete
  1883   wrapper names.  These names may be used to selectively delete
  1878   wrappers.
  1884   wrappers.
  1879 
  1885 
  1880   \begin{description}
  1886   \begin{description}
  1881 
  1887