merged
authorblanchet
Thu Oct 29 12:09:32 2009 +0100 (2009-10-29)
changeset 335661c62ac4ef6d1
parent 33300 939ca97f5a11
parent 33565 5fad8e36dfb1
child 33567 3b8fc89a52b7
merged
src/HOL/IsaMakefile
src/HOL/Tools/Nitpick/nitpick.ML
src/HOL/Tools/Nitpick/nitpick_isar.ML
src/Tools/quickcheck.ML
     1.1 --- a/doc-src/Nitpick/nitpick.tex	Thu Oct 29 11:26:47 2009 +0100
     1.2 +++ b/doc-src/Nitpick/nitpick.tex	Thu Oct 29 12:09:32 2009 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4  \usepackage[T1]{fontenc}
     1.5  \usepackage{amsmath}
     1.6  \usepackage{amssymb}
     1.7 -\usepackage[french,english]{babel}
     1.8 +\usepackage[english,french]{babel}
     1.9  \usepackage{color}
    1.10  \usepackage{graphicx}
    1.11  %\usepackage{mathpazo}
    1.12 @@ -40,6 +40,8 @@
    1.13  
    1.14  \begin{document}
    1.15  
    1.16 +\selectlanguage{english}
    1.17 +
    1.18  \title{\includegraphics[scale=0.5]{isabelle_nitpick} \\[4ex]
    1.19  Picking Nits \\[\smallskipamount]
    1.20  \Large A User's Guide to Nitpick for Isabelle/HOL 2010}
    1.21 @@ -112,6 +114,13 @@
    1.22  machine called \texttt{java}. The examples presented in this manual can be found
    1.23  in Isabelle's \texttt{src/HOL/Nitpick\_Examples/Manual\_Nits.thy} theory.
    1.24  
    1.25 +Throughout this manual, we will explicitly invoke the \textbf{nitpick} command.
    1.26 +Nitpick also provides an automatic mode that can be enabled using the
    1.27 +``Auto Nitpick'' option from the ``Isabelle'' menu in Proof General. In this
    1.28 +mode, Nitpick is run on every newly entered theorem, much like Auto Quickcheck.
    1.29 +The collective time limit for Auto Nitpick and Auto Quickcheck can be set using
    1.30 +the ``Auto Counterexample Time Limit'' option.
    1.31 +
    1.32  \newbox\boxA
    1.33  \setbox\boxA=\hbox{\texttt{nospam}}
    1.34  
    1.35 @@ -154,16 +163,6 @@
    1.36  configured SAT solvers in Isabelle (e.g., for Refute), these will also be
    1.37  available to Nitpick.
    1.38  
    1.39 -Throughout this manual, we will explicitly invoke the \textbf{nitpick} command.
    1.40 -Nitpick also provides an automatic mode that can be enabled by specifying
    1.41 -
    1.42 -\prew
    1.43 -\textbf{nitpick\_params} [\textit{auto}]
    1.44 -\postw
    1.45 -
    1.46 -at the beginning of the theory file. In this mode, Nitpick is run for up to 5
    1.47 -seconds (by default) on every newly entered theorem, much like Auto Quickcheck.
    1.48 -
    1.49  \subsection{Propositional Logic}
    1.50  \label{propositional-logic}
    1.51  
    1.52 @@ -1595,6 +1594,17 @@
    1.53  (\S\ref{authentication}), optimizations
    1.54  (\S\ref{optimizations}), and timeouts (\S\ref{timeouts}).
    1.55  
    1.56 +You can instruct Nitpick to run automatically on newly entered theorems by
    1.57 +enabling the ``Auto Nitpick'' option from the ``Isabelle'' menu in Proof
    1.58 +General. For automatic runs, \textit{user\_axioms} (\S\ref{mode-of-operation})
    1.59 +and \textit{assms} (\S\ref{mode-of-operation}) are implicitly enabled,
    1.60 +\textit{blocking} (\S\ref{mode-of-operation}), \textit{verbose}
    1.61 +(\S\ref{output-format}), and \textit{debug} (\S\ref{output-format}) are
    1.62 +disabled, \textit{max\_potential} (\S\ref{output-format}) is taken to be 0, and
    1.63 +\textit{timeout} (\S\ref{timeouts}) is superseded by the ``Auto Counterexample
    1.64 +Time Limit'' in Proof General's ``Isabelle'' menu. Nitpick's output is also more
    1.65 +concise.
    1.66 +
    1.67  The number of options can be overwhelming at first glance. Do not let that worry
    1.68  you: Nitpick's defaults have been chosen so that it almost always does the right
    1.69  thing, and the most important options have been covered in context in
    1.70 @@ -1622,35 +1632,19 @@
    1.71  \end{enum}
    1.72  
    1.73  Default values are indicated in square brackets. Boolean options have a negated
    1.74 -counterpart (e.g., \textit{auto} vs.\ \textit{no\_auto}). When setting Boolean
    1.75 -options, ``= \textit{true}'' may be omitted.
    1.76 +counterpart (e.g., \textit{blocking} vs.\ \textit{no\_blocking}). When setting
    1.77 +Boolean options, ``= \textit{true}'' may be omitted.
    1.78  
    1.79  \subsection{Mode of Operation}
    1.80  \label{mode-of-operation}
    1.81  
    1.82  \begin{enum}
    1.83 -\opfalse{auto}{no\_auto}
    1.84 -Specifies whether Nitpick should be run automatically on newly entered theorems.
    1.85 -For automatic runs, \textit{user\_axioms} (\S\ref{mode-of-operation}) and
    1.86 -\textit{assms} (\S\ref{mode-of-operation}) are implicitly enabled,
    1.87 -\textit{blocking} (\S\ref{mode-of-operation}), \textit{verbose}
    1.88 -(\S\ref{output-format}), and \textit{debug} (\S\ref{output-format}) are
    1.89 -disabled, \textit{max\_potential} (\S\ref{output-format}) is taken to be 0, and
    1.90 -\textit{auto\_timeout} (\S\ref{timeouts}) is used as the time limit instead of
    1.91 -\textit{timeout} (\S\ref{timeouts}). The output is also more concise.
    1.92 -
    1.93 -\nopagebreak
    1.94 -{\small See also \textit{auto\_timeout} (\S\ref{timeouts}).}
    1.95 -
    1.96  \optrue{blocking}{non\_blocking}
    1.97  Specifies whether the \textbf{nitpick} command should operate synchronously.
    1.98  The asynchronous (non-blocking) mode lets the user start proving the putative
    1.99  theorem while Nitpick looks for a counterexample, but it can also be more
   1.100  confusing. For technical reasons, automatic runs currently always block.
   1.101  
   1.102 -\nopagebreak
   1.103 -{\small See also \textit{auto} (\S\ref{mode-of-operation}).}
   1.104 -
   1.105  \optrue{falsify}{satisfy}
   1.106  Specifies whether Nitpick should look for falsifying examples (countermodels) or
   1.107  satisfying examples (models). This manual assumes throughout that
   1.108 @@ -1670,16 +1664,15 @@
   1.109  considered.
   1.110  
   1.111  \nopagebreak
   1.112 -{\small See also \textit{auto} (\S\ref{mode-of-operation}), \textit{assms}
   1.113 -(\S\ref{mode-of-operation}), and \textit{debug} (\S\ref{output-format}).}
   1.114 +{\small See also \textit{assms} (\S\ref{mode-of-operation}) and \textit{debug}
   1.115 +(\S\ref{output-format}).}
   1.116  
   1.117  \optrue{assms}{no\_assms}
   1.118  Specifies whether the relevant assumptions in structured proof should be
   1.119  considered. The option is implicitly enabled for automatic runs.
   1.120  
   1.121  \nopagebreak
   1.122 -{\small See also \textit{auto} (\S\ref{mode-of-operation})
   1.123 -and \textit{user\_axioms} (\S\ref{mode-of-operation}).}
   1.124 +{\small See also \textit{user\_axioms} (\S\ref{mode-of-operation}).}
   1.125  
   1.126  \opfalse{overlord}{no\_overlord}
   1.127  Specifies whether Nitpick should put its temporary files in
   1.128 @@ -1836,14 +1829,14 @@
   1.129  
   1.130  \nopagebreak
   1.131  {\small See also \textit{card} (\S\ref{scope-of-search}),
   1.132 -\textit{coalesce\_type\_vars} (\S\ref{scope-of-search}), and \textit{verbose}
   1.133 +\textit{merge\_type\_vars} (\S\ref{scope-of-search}), and \textit{verbose}
   1.134  (\S\ref{output-format}).}
   1.135  
   1.136  \opsmart{mono}{non\_box}
   1.137  Specifies the default monotonicity setting to use. This can be overridden on a
   1.138  per-type basis using the \textit{mono}~\qty{type} option described above.
   1.139  
   1.140 -\opfalse{coalesce\_type\_vars}{dont\_coalesce\_type\_vars}
   1.141 +\opfalse{merge\_type\_vars}{dont\_merge\_type\_vars}
   1.142  Specifies whether type variables with the same sort constraints should be
   1.143  merged. Setting this option to \textit{true} can reduce the number of scopes
   1.144  tried and the size of the generated Kodkod formulas, but it also diminishes the
   1.145 @@ -1861,9 +1854,6 @@
   1.146  option is useful to determine which scopes are tried or which SAT solver is
   1.147  used. This option is implicitly disabled for automatic runs.
   1.148  
   1.149 -\nopagebreak
   1.150 -{\small See also \textit{auto} (\S\ref{mode-of-operation}).}
   1.151 -
   1.152  \opfalse{debug}{no\_debug}
   1.153  Specifies whether Nitpick should display additional debugging information beyond
   1.154  what \textit{verbose} already displays. Enabling \textit{debug} also enables
   1.155 @@ -1871,8 +1861,8 @@
   1.156  option is implicitly disabled for automatic runs.
   1.157  
   1.158  \nopagebreak
   1.159 -{\small See also \textit{auto} (\S\ref{mode-of-operation}), \textit{overlord}
   1.160 -(\S\ref{mode-of-operation}), and \textit{batch\_size} (\S\ref{optimizations}).}
   1.161 +{\small See also \textit{overlord} (\S\ref{mode-of-operation}) and
   1.162 +\textit{batch\_size} (\S\ref{optimizations}).}
   1.163  
   1.164  \optrue{show\_skolems}{hide\_skolem}
   1.165  Specifies whether the values of Skolem constants should be displayed as part of
   1.166 @@ -1910,8 +1900,7 @@
   1.167  enabled.
   1.168  
   1.169  \nopagebreak
   1.170 -{\small See also \textit{auto} (\S\ref{mode-of-operation}),
   1.171 -\textit{check\_potential} (\S\ref{authentication}), and
   1.172 +{\small See also \textit{check\_potential} (\S\ref{authentication}) and
   1.173  \textit{sat\_solver} (\S\ref{optimizations}).}
   1.174  
   1.175  \opt{max\_genuine}{int}{$\mathbf{1}$}
   1.176 @@ -1968,8 +1957,7 @@
   1.177  shown to be genuine, Nitpick displays a message to this effect and terminates.
   1.178  
   1.179  \nopagebreak
   1.180 -{\small See also \textit{max\_potential} (\S\ref{output-format}) and
   1.181 -\textit{auto\_timeout} (\S\ref{timeouts}).}
   1.182 +{\small See also \textit{max\_potential} (\S\ref{output-format}).}
   1.183  
   1.184  \opfalse{check\_genuine}{trust\_genuine}
   1.185  Specifies whether genuine and likely genuine counterexamples should be given to
   1.186 @@ -1979,8 +1967,7 @@
   1.187  \texttt{blan{\color{white}nospam}\kern-\wd\boxA{}chette@in.tum.de}.
   1.188  
   1.189  \nopagebreak
   1.190 -{\small See also \textit{max\_genuine} (\S\ref{output-format}) and
   1.191 -\textit{auto\_timeout} (\S\ref{timeouts}).}
   1.192 +{\small See also \textit{max\_genuine} (\S\ref{output-format}).}
   1.193  
   1.194  \ops{expect}{string}
   1.195  Specifies the expected outcome, which must be one of the following:
   1.196 @@ -2206,21 +2193,14 @@
   1.197  Specifies the maximum amount of time that the \textbf{nitpick} command should
   1.198  spend looking for a counterexample. Nitpick tries to honor this constraint as
   1.199  well as it can but offers no guarantees. For automatic runs,
   1.200 -\textit{auto\_timeout} is used instead.
   1.201 +\textit{timeout} is ignored; instead, Auto Quickcheck and Auto Nitpick share
   1.202 +a time slot whose length is specified by the ``Auto Counterexample Time
   1.203 +Limit'' option in Proof General.
   1.204  
   1.205  \nopagebreak
   1.206 -{\small See also \textit{auto} (\S\ref{mode-of-operation})
   1.207 -and \textit{max\_threads} (\S\ref{optimizations}).}
   1.208 -
   1.209 -\opt{auto\_timeout}{time}{$\mathbf{5}$ s}
   1.210 -Specifies the maximum amount of time that Nitpick should use to find a
   1.211 -counterexample when running automatically. Nitpick tries to honor this
   1.212 -constraint as well as it can but offers no guarantees.
   1.213 -
   1.214 -\nopagebreak
   1.215 -{\small See also \textit{auto} (\S\ref{mode-of-operation}).}
   1.216 -
   1.217 -\opt{tac\_timeout}{time}{$\mathbf{500}$ ms}
   1.218 +{\small See also \textit{max\_threads} (\S\ref{optimizations}).}
   1.219 +
   1.220 +\opt{tac\_timeout}{time}{$\mathbf{500}$\,ms}
   1.221  Specifies the maximum amount of time that the \textit{auto} tactic should use
   1.222  when checking a counterexample, and similarly that \textit{lexicographic\_order}
   1.223  and \textit{sizechange} should use when checking whether a (co)in\-duc\-tive
   1.224 @@ -2398,11 +2378,11 @@
   1.225  & \textit{subgoal}\end{aligned}$
   1.226  \postw
   1.227  
   1.228 +\let\antiq=\textrm
   1.229 +
   1.230  \subsection{Registration of Coinductive Datatypes}
   1.231  \label{registration-of-coinductive-datatypes}
   1.232  
   1.233 -\let\antiq=\textrm
   1.234 -
   1.235  If you have defined a custom coinductive datatype, you can tell Nitpick about
   1.236  it, so that it can use an efficient Kodkod axiomatization similar to the one it
   1.237  uses for lazy lists. The interface for registering and unregistering coinductive
   1.238 @@ -2467,6 +2447,12 @@
   1.239  representation of functions synthesized by Isabelle, which is an implementation
   1.240  detail.
   1.241  
   1.242 +\item[$\bullet$] Nitpick maintains a global cache of wellfoundedness conditions,
   1.243 +which can become invalid if you change the definition of an inductive predicate
   1.244 +that is registered in the cache. To clear the cache,
   1.245 +run Nitpick with the \textit{tac\_timeout} option set to a new value (e.g.,
   1.246 +501$\,\textit{ms}$).
   1.247 +
   1.248  \item[$\bullet$] Nitpick produces spurious counterexamples when invoked after a
   1.249  \textbf{guess} command in a structured proof.
   1.250  
     2.1 Binary file doc-src/gfx/isabelle_nitpick.pdf has changed
     3.1 --- a/src/HOL/IsaMakefile	Thu Oct 29 11:26:47 2009 +0100
     3.2 +++ b/src/HOL/IsaMakefile	Thu Oct 29 12:09:32 2009 +0100
     3.3 @@ -102,6 +102,7 @@
     3.4    $(SRC)/Provers/hypsubst.ML \
     3.5    $(SRC)/Provers/quantifier1.ML \
     3.6    $(SRC)/Provers/splitter.ML \
     3.7 +  $(SRC)/Tools/Auto_Counterexample.thy \
     3.8    $(SRC)/Tools/Code/code_haskell.ML \
     3.9    $(SRC)/Tools/Code/code_ml.ML \
    3.10    $(SRC)/Tools/Code/code_preproc.ML \
    3.11 @@ -114,6 +115,7 @@
    3.12    $(SRC)/Tools/IsaPlanner/rw_tools.ML \
    3.13    $(SRC)/Tools/IsaPlanner/zipper.ML \
    3.14    $(SRC)/Tools/atomize_elim.ML \
    3.15 +  $(SRC)/Tools/auto_counterexample.ML \
    3.16    $(SRC)/Tools/auto_solve.ML \
    3.17    $(SRC)/Tools/coherent.ML \
    3.18    $(SRC)/Tools/cong_tac.ML \
     4.1 --- a/src/HOL/Main.thy	Thu Oct 29 11:26:47 2009 +0100
     4.2 +++ b/src/HOL/Main.thy	Thu Oct 29 12:09:32 2009 +0100
     4.3 @@ -1,7 +1,7 @@
     4.4  header {* Main HOL *}
     4.5  
     4.6  theory Main
     4.7 -imports Plain Nitpick Predicate_Compile Recdef
     4.8 +imports Plain Nitpick
     4.9  begin
    4.10  
    4.11  text {*
     5.1 --- a/src/HOL/Nitpick.thy	Thu Oct 29 11:26:47 2009 +0100
     5.2 +++ b/src/HOL/Nitpick.thy	Thu Oct 29 12:09:32 2009 +0100
     5.3 @@ -8,7 +8,7 @@
     5.4  header {* Nitpick: Yet Another Counterexample Generator for Isabelle/HOL *}
     5.5  
     5.6  theory Nitpick
     5.7 -imports Map SAT
     5.8 +imports Map Quickcheck SAT
     5.9  uses ("Tools/Nitpick/kodkod.ML")
    5.10       ("Tools/Nitpick/kodkod_sat.ML")
    5.11       ("Tools/Nitpick/nitpick_util.ML")
    5.12 @@ -117,12 +117,16 @@
    5.13   apply (simp only: unit.cases)
    5.14  by simp
    5.15  
    5.16 +declare unit.cases [nitpick_simp del]
    5.17 +
    5.18  lemma nat_case_def [nitpick_def]:
    5.19  "nat_case x f n \<equiv> if n = 0 then x else f (n - 1)"
    5.20  apply (rule eq_reflection)
    5.21  by (case_tac n) auto
    5.22  
    5.23 -lemmas dvd_def = dvd_eq_mod_eq_0 [THEN eq_reflection, nitpick_def]
    5.24 +declare nat.cases [nitpick_simp del]
    5.25 +
    5.26 +lemmas [nitpick_def] = dvd_eq_mod_eq_0 [THEN eq_reflection]
    5.27  
    5.28  lemma list_size_simp [nitpick_simp]:
    5.29  "list_size f xs = (if xs = [] then 0
    5.30 @@ -206,6 +210,21 @@
    5.31  definition of_frac :: "'a \<Rightarrow> 'b\<Colon>{inverse,ring_1}" where
    5.32  "of_frac q \<equiv> of_int (num q) / of_int (denom q)"
    5.33  
    5.34 +(* While Nitpick normally avoids to unfold definitions for locales, it
    5.35 +   unfortunately needs to unfold them when dealing with the following built-in
    5.36 +   constants. A cleaner approach would be to change "Nitpick_HOL" and
    5.37 +   "Nitpick_Nits" so that they handle the unexpanded overloaded constants
    5.38 +   directly, but this is slightly more tricky to implement. *)
    5.39 +lemmas [nitpick_def] = div_int_inst.div_int div_int_inst.mod_int
    5.40 +    div_nat_inst.div_nat div_nat_inst.mod_nat lower_semilattice_fun_inst.inf_fun
    5.41 +    minus_fun_inst.minus_fun minus_int_inst.minus_int minus_nat_inst.minus_nat
    5.42 +    one_int_inst.one_int one_nat_inst.one_nat ord_fun_inst.less_eq_fun
    5.43 +    ord_int_inst.less_eq_int ord_int_inst.less_int ord_nat_inst.less_eq_nat
    5.44 +    ord_nat_inst.less_nat plus_int_inst.plus_int plus_nat_inst.plus_nat
    5.45 +    times_int_inst.times_int times_nat_inst.times_nat uminus_int_inst.uminus_int
    5.46 +    upper_semilattice_fun_inst.sup_fun zero_int_inst.zero_int
    5.47 +    zero_nat_inst.zero_nat
    5.48 +
    5.49  use "Tools/Nitpick/kodkod.ML"
    5.50  use "Tools/Nitpick/kodkod_sat.ML"
    5.51  use "Tools/Nitpick/nitpick_util.ML"
    5.52 @@ -222,6 +241,8 @@
    5.53  use "Tools/Nitpick/nitpick_tests.ML"
    5.54  use "Tools/Nitpick/minipick.ML"
    5.55  
    5.56 +setup {* Nitpick_Isar.setup *}
    5.57 +
    5.58  hide (open) const unknown undefined_fast_The undefined_fast_Eps bisim 
    5.59      bisim_iterator_max Tha refl' wf' wf_wfrec wf_wfrec' wfrec' card' setsum'
    5.60      fold_graph' nat_gcd nat_lcm int_gcd int_lcm Frac Abs_Frac Rep_Frac zero_frac
    5.61 @@ -230,10 +251,10 @@
    5.62  hide (open) type bisim_iterator pair_box fun_box
    5.63  hide (open) fact If_def Ex1_def rtrancl_def rtranclp_def tranclp_def refl'_def
    5.64      wf'_def wf_wfrec'_def wfrec'_def card'_def setsum'_def fold_graph'_def
    5.65 -    The_psimp Eps_psimp unit_case_def nat_case_def dvd_def list_size_simp
    5.66 -    nat_gcd_def nat_lcm_def int_gcd_def int_lcm_def Frac_def zero_frac_def
    5.67 -    one_frac_def num_def denom_def norm_frac_def frac_def plus_frac_def
    5.68 -    times_frac_def uminus_frac_def number_of_frac_def inverse_frac_def
    5.69 -    less_eq_frac_def of_frac_def
    5.70 +    The_psimp Eps_psimp unit_case_def nat_case_def list_size_simp nat_gcd_def
    5.71 +    nat_lcm_def int_gcd_def int_lcm_def Frac_def zero_frac_def one_frac_def
    5.72 +    num_def denom_def norm_frac_def frac_def plus_frac_def times_frac_def
    5.73 +    uminus_frac_def number_of_frac_def inverse_frac_def less_eq_frac_def
    5.74 +    of_frac_def
    5.75  
    5.76  end
     6.1 --- a/src/HOL/Quickcheck.thy	Thu Oct 29 11:26:47 2009 +0100
     6.2 +++ b/src/HOL/Quickcheck.thy	Thu Oct 29 12:09:32 2009 +0100
     6.3 @@ -126,6 +126,8 @@
     6.4    shows "random_aux k = rhs k"
     6.5    using assms by (rule code_numeral.induct)
     6.6  
     6.7 +setup {* Quickcheck.setup *}
     6.8 +
     6.9  subsection {* the Random-Predicate Monad *} 
    6.10  
    6.11  types 'a randompred = "Random.seed \<Rightarrow> ('a Predicate.pred \<times> Random.seed)"
     7.1 --- a/src/HOL/Tools/Nitpick/HISTORY	Thu Oct 29 11:26:47 2009 +0100
     7.2 +++ b/src/HOL/Tools/Nitpick/HISTORY	Thu Oct 29 12:09:32 2009 +0100
     7.3 @@ -6,7 +6,11 @@
     7.4      "nitpick_ind_intro" to "nitpick_intro"
     7.5    * Replaced "special_depth" and "skolemize_depth" options by "specialize"
     7.6      and "skolemize"
     7.7 +  * Renamed "coalesce_type_vars" to "merge_type_vars"
     7.8 +  * Optimized Kodkod encoding of datatypes whose constructors don't appear in
     7.9 +    the formula to falsify
    7.10    * Fixed monotonicity check
    7.11 +  * Fixed error in display of uncurried constants
    7.12  
    7.13  Version 1.2.2 (16 Oct 2009)
    7.14  
     8.1 --- a/src/HOL/Tools/Nitpick/nitpick.ML	Thu Oct 29 11:26:47 2009 +0100
     8.2 +++ b/src/HOL/Tools/Nitpick/nitpick.ML	Thu Oct 29 12:09:32 2009 +0100
     8.3 @@ -23,7 +23,7 @@
     8.4      overlord: bool,
     8.5      user_axioms: bool option,
     8.6      assms: bool,
     8.7 -    coalesce_type_vars: bool,
     8.8 +    merge_type_vars: bool,
     8.9      destroy_constrs: bool,
    8.10      specialize: bool,
    8.11      skolemize: bool,
    8.12 @@ -88,7 +88,7 @@
    8.13    overlord: bool,
    8.14    user_axioms: bool option,
    8.15    assms: bool,
    8.16 -  coalesce_type_vars: bool,
    8.17 +  merge_type_vars: bool,
    8.18    destroy_constrs: bool,
    8.19    specialize: bool,
    8.20    skolemize: bool,
    8.21 @@ -175,7 +175,7 @@
    8.22      val ctxt = Proof.context_of state
    8.23      val {cards_assigns, maxes_assigns, iters_assigns, bisim_depths, boxes,
    8.24           monos, wfs, sat_solver, blocking, falsify, debug, verbose, overlord,
    8.25 -         user_axioms, assms, coalesce_type_vars, destroy_constrs, specialize,
    8.26 +         user_axioms, assms, merge_type_vars, destroy_constrs, specialize,
    8.27           skolemize, star_linear_preds, uncurry, fast_descrs, peephole_optim,
    8.28           tac_timeout, sym_break, sharing_depth, flatten_props, max_threads,
    8.29           show_skolems, show_datatypes, show_consts, evals, formats,
    8.30 @@ -187,7 +187,7 @@
    8.31      val pprint =
    8.32        if auto then
    8.33          Unsynchronized.change state_ref o Proof.goal_message o K
    8.34 -        o curry Pretty.blk 0 o cons (Pretty.str "") o single
    8.35 +        o Pretty.chunks o cons (Pretty.str "") o single
    8.36          o Pretty.mark Markup.hilite
    8.37        else
    8.38          priority o Pretty.string_of
    8.39 @@ -220,7 +220,7 @@
    8.40                      neg_t
    8.41      val (assms_t, evals) =
    8.42        assms_t :: evals
    8.43 -      |> coalesce_type_vars ? coalesce_type_vars_in_terms
    8.44 +      |> merge_type_vars ? merge_type_vars_in_terms
    8.45        |> hd pairf tl
    8.46      val original_max_potential = max_potential
    8.47      val original_max_genuine = max_genuine
    8.48 @@ -283,6 +283,21 @@
    8.49              handle TYPE (_, Ts, ts) =>
    8.50                     raise TYPE ("Nitpick.pick_them_nits_in_term", Ts, ts)
    8.51  
    8.52 +    val core_u = nut_from_term thy fast_descrs (!special_funs) Eq core_t
    8.53 +    val def_us = map (nut_from_term thy fast_descrs (!special_funs) DefEq)
    8.54 +                     def_ts
    8.55 +    val nondef_us = map (nut_from_term thy fast_descrs (!special_funs) Eq)
    8.56 +                        nondef_ts
    8.57 +    val (free_names, const_names) =
    8.58 +      fold add_free_and_const_names (core_u :: def_us @ nondef_us) ([], [])
    8.59 +    val (sel_names, nonsel_names) =
    8.60 +      List.partition (is_sel o nickname_of) const_names
    8.61 +    val would_be_genuine = got_all_user_axioms andalso none_true wfs
    8.62 +(*
    8.63 +    val _ = List.app (priority o string_for_nut ctxt)
    8.64 +                     (core_u :: def_us @ nondef_us)
    8.65 +*)
    8.66 +
    8.67      val unique_scope = forall (equal 1 o length o snd) cards_assigns
    8.68      (* typ -> bool *)
    8.69      fun is_free_type_monotonic T =
    8.70 @@ -298,6 +313,8 @@
    8.71          not (is_pure_typedef thy T) orelse is_univ_typedef thy T
    8.72          orelse is_number_type thy T
    8.73          orelse formulas_monotonic ext_ctxt T def_ts nondef_ts core_t
    8.74 +    fun is_datatype_shallow T =
    8.75 +      not (exists (equal T o domain_type o type_of) sel_names)
    8.76      val Ts = ground_types_in_terms ext_ctxt (core_t :: def_ts @ nondef_ts)
    8.77               |> sort TermOrd.typ_ord
    8.78      val (all_dataTs, all_free_Ts) =
    8.79 @@ -326,7 +343,7 @@
    8.80          ()
    8.81      val mono_Ts = mono_dataTs @ mono_free_Ts
    8.82      val nonmono_Ts = nonmono_dataTs @ nonmono_free_Ts
    8.83 -
    8.84 +    val shallow_dataTs = filter is_datatype_shallow mono_dataTs
    8.85  (*
    8.86      val _ = priority "Monotonic datatypes:"
    8.87      val _ = List.app (priority o string_for_type ctxt) mono_dataTs
    8.88 @@ -338,19 +355,6 @@
    8.89      val _ = List.app (priority o string_for_type ctxt) nonmono_free_Ts
    8.90  *)
    8.91  
    8.92 -    val core_u = nut_from_term thy fast_descrs (!special_funs) Eq core_t
    8.93 -    val def_us = map (nut_from_term thy fast_descrs (!special_funs) DefEq)
    8.94 -                     def_ts
    8.95 -    val nondef_us = map (nut_from_term thy fast_descrs (!special_funs) Eq)
    8.96 -                        nondef_ts
    8.97 -    val (free_names, const_names) =
    8.98 -      fold add_free_and_const_names (core_u :: def_us @ nondef_us) ([], [])
    8.99 -    val nonsel_names = filter_out (is_sel o nickname_of) const_names
   8.100 -    val would_be_genuine = got_all_user_axioms andalso none_true wfs
   8.101 -(*
   8.102 -    val _ = List.app (priority o string_for_nut ctxt)
   8.103 -                     (core_u :: def_us @ nondef_us)
   8.104 -*)
   8.105      val need_incremental = Int.max (max_potential, max_genuine) >= 2
   8.106      val effective_sat_solver =
   8.107        if sat_solver <> "smart" then
   8.108 @@ -778,11 +782,9 @@
   8.109                     case scope_count (do_filter (!generated_problems)) scope of
   8.110                       0 => I
   8.111                     | n =>
   8.112 -                     if scope_count (do_filter (these (!checked_problems)))
   8.113 -                                    scope = n then
   8.114 -                       Integer.add 1
   8.115 -                     else
   8.116 -                       I) (!generated_scopes) 0
   8.117 +                     scope_count (do_filter (these (!checked_problems)))
   8.118 +                                 scope = n
   8.119 +                     ? Integer.add 1) (!generated_scopes) 0
   8.120        in
   8.121          "Nitpick " ^ did_so_and_so ^
   8.122          (if is_some (!checked_problems) andalso total > 0 then
   8.123 @@ -814,6 +816,7 @@
   8.124  
   8.125      val _ = scopes := all_scopes ext_ctxt sym_break cards_assigns maxes_assigns
   8.126                                   iters_assigns bisim_depths mono_Ts nonmono_Ts
   8.127 +                                 shallow_dataTs
   8.128      val batches = batch_list batch_size (!scopes)
   8.129      val outcome_code =
   8.130        (run_batches 0 (length batches) batches (max_potential, max_genuine, 0)
     9.1 --- a/src/HOL/Tools/Nitpick/nitpick_hol.ML	Thu Oct 29 11:26:47 2009 +0100
     9.2 +++ b/src/HOL/Tools/Nitpick/nitpick_hol.ML	Thu Oct 29 12:09:32 2009 +0100
     9.3 @@ -125,7 +125,7 @@
     9.4    val is_inductive_pred : extended_context -> styp -> bool
     9.5    val is_constr_pattern_lhs : theory -> term -> bool
     9.6    val is_constr_pattern_formula : theory -> term -> bool
     9.7 -  val coalesce_type_vars_in_terms : term list -> term list
     9.8 +  val merge_type_vars_in_terms : term list -> term list
     9.9    val ground_types_in_type : extended_context -> typ -> typ list
    9.10    val ground_types_in_terms : extended_context -> term list -> typ list
    9.11    val format_type : int list -> int list -> typ -> typ
    9.12 @@ -1016,24 +1016,6 @@
    9.13        | do_eq _ = false
    9.14    in do_eq end
    9.15  
    9.16 -(* This table is not pretty. A better approach would be to avoid expanding the
    9.17 -   operators to their low-level definitions, but this would require dealing with
    9.18 -   overloading. *)
    9.19 -val built_in_built_in_defs =
    9.20 -  [@{thm div_int_inst.div_int}, @{thm div_int_inst.mod_int},
    9.21 -   @{thm div_nat_inst.div_nat}, @{thm div_nat_inst.mod_nat},
    9.22 -   @{thm lower_semilattice_fun_inst.inf_fun}, @{thm minus_fun_inst.minus_fun},
    9.23 -   @{thm minus_int_inst.minus_int}, @{thm minus_nat_inst.minus_nat},
    9.24 -   @{thm one_int_inst.one_int}, @{thm one_nat_inst.one_nat},
    9.25 -   @{thm ord_fun_inst.less_eq_fun}, @{thm ord_int_inst.less_eq_int},
    9.26 -   @{thm ord_int_inst.less_int}, @{thm ord_nat_inst.less_eq_nat},
    9.27 -   @{thm ord_nat_inst.less_nat}, @{thm plus_int_inst.plus_int},
    9.28 -   @{thm plus_nat_inst.plus_nat}, @{thm times_int_inst.times_int},
    9.29 -   @{thm times_nat_inst.times_nat}, @{thm uminus_int_inst.uminus_int},
    9.30 -   @{thm upper_semilattice_fun_inst.sup_fun}, @{thm zero_int_inst.zero_int},
    9.31 -   @{thm zero_nat_inst.zero_nat}]
    9.32 -  |> map prop_of
    9.33 -
    9.34  (* theory -> term list * term list * term list *)
    9.35  fun all_axioms_of thy =
    9.36    let
    9.37 @@ -1054,8 +1036,7 @@
    9.38      val (built_in_nondefs, user_nondefs) =
    9.39        List.partition (is_typedef_axiom thy false) user_nondefs
    9.40        |>> append built_in_nondefs
    9.41 -    val defs = built_in_built_in_defs @
    9.42 -               (thy |> PureThy.all_thms_of
    9.43 +    val defs = (thy |> PureThy.all_thms_of
    9.44                      |> filter (equal Thm.definitionK o Thm.get_kind o snd)
    9.45                      |> map (prop_of o snd) |> filter is_plain_definition) @
    9.46                 user_defs @ built_in_defs
    9.47 @@ -1309,10 +1290,6 @@
    9.48      |> fold_rev (curry absdummy) (func_Ts @ [dataT])
    9.49    end
    9.50  
    9.51 -val redefined_in_Nitpick_thy =
    9.52 -  [@{const_name option_case}, @{const_name nat_case}, @{const_name list_case},
    9.53 -   @{const_name list_size}]
    9.54 -
    9.55  (* theory -> string -> typ -> typ -> term -> term *)
    9.56  fun optimized_record_get thy s rec_T res_T t =
    9.57    let val constr_x = the_single (datatype_constrs thy rec_T) in
    9.58 @@ -1382,7 +1359,6 @@
    9.59    (is_real_equational_fun ext_ctxt orf is_real_inductive_pred ext_ctxt
    9.60     orf (String.isPrefix ubfp_prefix orf String.isPrefix lbfp_prefix) o fst)
    9.61    andf (not o has_trivial_definition thy def_table)
    9.62 -  andf (not o member (op =) redefined_in_Nitpick_thy o fst)
    9.63  
    9.64  (* term * term -> term *)
    9.65  fun s_betapply (Const (@{const_name If}, _) $ @{const True} $ t, _) = t
    9.66 @@ -1630,6 +1606,7 @@
    9.67                                   (tac ctxt (auto_tac (clasimpset_of ctxt))))
    9.68         #> the #> Goal.finish ctxt) goal
    9.69  
    9.70 +val max_cached_wfs = 100
    9.71  val cached_timeout = Unsynchronized.ref (SOME Time.zeroTime)
    9.72  val cached_wf_props : (term * bool) list Unsynchronized.ref =
    9.73    Unsynchronized.ref []
    9.74 @@ -1663,8 +1640,11 @@
    9.75                   else
    9.76                     ()
    9.77         in
    9.78 -         if tac_timeout = (!cached_timeout) then ()
    9.79 -         else (cached_wf_props := []; cached_timeout := tac_timeout);
    9.80 +         if tac_timeout = (!cached_timeout)
    9.81 +            andalso length (!cached_wf_props) < max_cached_wfs then
    9.82 +           ()
    9.83 +         else
    9.84 +           (cached_wf_props := []; cached_timeout := tac_timeout);
    9.85           case AList.lookup (op =) (!cached_wf_props) prop of
    9.86             SOME wf => wf
    9.87           | NONE =>
    9.88 @@ -1879,9 +1859,7 @@
    9.89  (* extended_context -> styp -> term list *)
    9.90  fun raw_equational_fun_axioms (ext_ctxt as {thy, fast_descrs, simp_table,
    9.91                                              psimp_table, ...}) (x as (s, _)) =
    9.92 -  if s mem redefined_in_Nitpick_thy then
    9.93 -    []
    9.94 -  else case def_props_for_const thy fast_descrs (!simp_table) x of
    9.95 +  case def_props_for_const thy fast_descrs (!simp_table) x of
    9.96      [] => (case def_props_for_const thy fast_descrs psimp_table x of
    9.97               [] => [inductive_pred_axiom ext_ctxt x]
    9.98             | psimps => psimps)
    9.99 @@ -1890,7 +1868,7 @@
   9.100  val equational_fun_axioms = map extensionalize oo raw_equational_fun_axioms
   9.101  
   9.102  (* term list -> term list *)
   9.103 -fun coalesce_type_vars_in_terms ts =
   9.104 +fun merge_type_vars_in_terms ts =
   9.105    let
   9.106      (* typ -> (sort * string) list -> (sort * string) list *)
   9.107      fun add_type (TFree (s, S)) table =
    10.1 --- a/src/HOL/Tools/Nitpick/nitpick_isar.ML	Thu Oct 29 11:26:47 2009 +0100
    10.2 +++ b/src/HOL/Tools/Nitpick/nitpick_isar.ML	Thu Oct 29 12:09:32 2009 +0100
    10.3 @@ -10,7 +10,9 @@
    10.4  sig
    10.5    type params = Nitpick.params
    10.6  
    10.7 +  val auto: bool Unsynchronized.ref
    10.8    val default_params : theory -> (string * string) list -> params
    10.9 +  val setup : theory -> theory
   10.10  end
   10.11  
   10.12  structure Nitpick_Isar : NITPICK_ISAR =
   10.13 @@ -22,6 +24,14 @@
   10.14  open Nitpick_Nut
   10.15  open Nitpick
   10.16  
   10.17 +val auto = Unsynchronized.ref false;
   10.18 +
   10.19 +val _ = ProofGeneralPgip.add_preference Preferences.category_tracing
   10.20 +            (setmp_CRITICAL auto false
   10.21 +                 (fn () => Preferences.bool_pref auto
   10.22 +                               "auto-nitpick"
   10.23 +                               "Whether to run Nitpick automatically.") ())
   10.24 +
   10.25  type raw_param = string * string list
   10.26  
   10.27  val default_default_params =
   10.28 @@ -33,12 +43,11 @@
   10.29     ("wf", ["smart"]),
   10.30     ("sat_solver", ["smart"]),
   10.31     ("batch_size", ["smart"]),
   10.32 -   ("auto", ["false"]),
   10.33     ("blocking", ["true"]),
   10.34     ("falsify", ["true"]),
   10.35     ("user_axioms", ["smart"]),
   10.36     ("assms", ["true"]),
   10.37 -   ("coalesce_type_vars", ["false"]),
   10.38 +   ("merge_type_vars", ["false"]),
   10.39     ("destroy_constrs", ["true"]),
   10.40     ("specialize", ["true"]),
   10.41     ("skolemize", ["true"]),
   10.42 @@ -47,7 +56,6 @@
   10.43     ("fast_descrs", ["true"]),
   10.44     ("peephole_optim", ["true"]),
   10.45     ("timeout", ["30 s"]),
   10.46 -   ("auto_timeout", ["5 s"]),
   10.47     ("tac_timeout", ["500 ms"]),
   10.48     ("sym_break", ["20"]),
   10.49     ("sharing_depth", ["3"]),
   10.50 @@ -70,12 +78,11 @@
   10.51    [("dont_box", "box"),
   10.52     ("non_mono", "mono"),
   10.53     ("non_wf", "wf"),
   10.54 -   ("no_auto", "auto"),
   10.55     ("non_blocking", "blocking"),
   10.56     ("satisfy", "falsify"),
   10.57     ("no_user_axioms", "user_axioms"),
   10.58     ("no_assms", "assms"),
   10.59 -   ("dont_coalesce_type_vars", "coalesce_type_vars"),
   10.60 +   ("dont_merge_type_vars", "merge_type_vars"),
   10.61     ("dont_destroy_constrs", "destroy_constrs"),
   10.62     ("dont_specialize", "specialize"),
   10.63     ("dont_skolemize", "skolemize"),
   10.64 @@ -126,31 +133,22 @@
   10.65    | NONE => (name, value)
   10.66  
   10.67  structure TheoryData = TheoryDataFun(
   10.68 -  type T = {params: raw_param list, registered_auto: bool}
   10.69 -  val empty = {params = rev default_default_params, registered_auto = false}
   10.70 +  type T = {params: raw_param list}
   10.71 +  val empty = {params = rev default_default_params}
   10.72    val copy = I
   10.73    val extend = I
   10.74 -  fun merge _ ({params = ps1, registered_auto = a1},
   10.75 -               {params = ps2, registered_auto = a2}) =
   10.76 -    {params = AList.merge (op =) (op =) (ps1, ps2),
   10.77 -     registered_auto = a1 orelse a2})
   10.78 +  fun merge _ ({params = ps1}, {params = ps2}) =
   10.79 +    {params = AList.merge (op =) (op =) (ps1, ps2)})
   10.80  
   10.81  (* raw_param -> theory -> theory *)
   10.82  fun set_default_raw_param param thy =
   10.83 -  let val {params, registered_auto} = TheoryData.get thy in
   10.84 +  let val {params} = TheoryData.get thy in
   10.85      TheoryData.put
   10.86 -      {params = AList.update (op =) (unnegate_raw_param param) params,
   10.87 -       registered_auto = registered_auto} thy
   10.88 +        {params = AList.update (op =) (unnegate_raw_param param) params} thy
   10.89    end
   10.90  (* theory -> raw_param list *)
   10.91  val default_raw_params = #params o TheoryData.get
   10.92  
   10.93 -(* theory -> theory *)
   10.94 -fun set_registered_auto thy =
   10.95 -  TheoryData.put {params = default_raw_params thy, registered_auto = true} thy
   10.96 -(* theory -> bool *)
   10.97 -val is_registered_auto = #registered_auto o TheoryData.get
   10.98 -
   10.99  (* string -> bool *)
  10.100  fun is_punctuation s = (s = "," orelse s = "-" orelse s = "\<midarrow>")
  10.101  
  10.102 @@ -305,7 +303,7 @@
  10.103      val overlord = lookup_bool "overlord"
  10.104      val user_axioms = lookup_bool_option "user_axioms"
  10.105      val assms = lookup_bool "assms"
  10.106 -    val coalesce_type_vars = lookup_bool "coalesce_type_vars"
  10.107 +    val merge_type_vars = lookup_bool "merge_type_vars"
  10.108      val destroy_constrs = lookup_bool "destroy_constrs"
  10.109      val specialize = lookup_bool "specialize"
  10.110      val skolemize = lookup_bool "skolemize"
  10.111 @@ -313,8 +311,7 @@
  10.112      val uncurry = lookup_bool "uncurry"
  10.113      val fast_descrs = lookup_bool "fast_descrs"
  10.114      val peephole_optim = lookup_bool "peephole_optim"
  10.115 -    val timeout = if auto then lookup_time "auto_timeout"
  10.116 -                  else lookup_time "timeout"
  10.117 +    val timeout = if auto then NONE else lookup_time "timeout"
  10.118      val tac_timeout = lookup_time "tac_timeout"
  10.119      val sym_break = Int.max (0, lookup_int "sym_break")
  10.120      val sharing_depth = Int.max (1, lookup_int "sharing_depth")
  10.121 @@ -326,8 +323,8 @@
  10.122      val show_consts = show_all orelse lookup_bool "show_consts"
  10.123      val formats = lookup_ints_assigns read_term_polymorphic "format" 0
  10.124      val evals = lookup_term_list "eval"
  10.125 -    val max_potential = if auto then 0
  10.126 -                        else Int.max (0, lookup_int "max_potential")
  10.127 +    val max_potential =
  10.128 +      if auto then 0 else Int.max (0, lookup_int "max_potential")
  10.129      val max_genuine = Int.max (0, lookup_int "max_genuine")
  10.130      val check_potential = lookup_bool "check_potential"
  10.131      val check_genuine = lookup_bool "check_genuine"
  10.132 @@ -341,7 +338,7 @@
  10.133       monos = monos, wfs = wfs, sat_solver = sat_solver, blocking = blocking,
  10.134       falsify = falsify, debug = debug, verbose = verbose, overlord = overlord,
  10.135       user_axioms = user_axioms, assms = assms,
  10.136 -     coalesce_type_vars = coalesce_type_vars, destroy_constrs = destroy_constrs,
  10.137 +     merge_type_vars = merge_type_vars, destroy_constrs = destroy_constrs,
  10.138       specialize = specialize, skolemize = skolemize,
  10.139       star_linear_preds = star_linear_preds, uncurry = uncurry,
  10.140       fast_descrs = fast_descrs, peephole_optim = peephole_optim,
  10.141 @@ -412,7 +409,7 @@
  10.142         | Refute.REFUTE (loc, details) =>
  10.143           error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^ ".")
  10.144  
  10.145 -(* raw_param list -> bool -> int -> Proof.state -> Proof.state *)
  10.146 +(* raw_param list -> bool -> int -> Proof.state -> bool * Proof.state *)
  10.147  fun pick_nits override_params auto subgoal state =
  10.148    let
  10.149      val thy = Proof.theory_of state
  10.150 @@ -421,70 +418,49 @@
  10.151      val _ = List.app check_raw_param override_params
  10.152      val params as {blocking, debug, ...} =
  10.153        extract_params ctxt auto (default_raw_params thy) override_params
  10.154 -    (* unit -> Proof.state *)
  10.155 +    (* unit -> bool * Proof.state *)
  10.156      fun go () =
  10.157 -      (if auto then perhaps o try
  10.158 -       else if debug then fn f => fn x => f x
  10.159 -       else handle_exceptions ctxt)
  10.160 -      (fn state => pick_nits_in_subgoal state params auto subgoal |> snd)
  10.161 -      state
  10.162 +      (false, state)
  10.163 +      |> (if auto then perhaps o try
  10.164 +          else if debug then fn f => fn x => f x
  10.165 +          else handle_exceptions ctxt)
  10.166 +         (fn (_, state) => pick_nits_in_subgoal state params auto subgoal
  10.167 +                           |>> equal "genuine")
  10.168    in
  10.169 -    if auto orelse blocking then
  10.170 -      go ()
  10.171 -    else
  10.172 -      (SimpleThread.fork true (fn () => (go (); ()));
  10.173 -       state)
  10.174 +    if auto orelse blocking then go ()
  10.175 +    else (SimpleThread.fork true (fn () => (go (); ())); (false, state))
  10.176    end
  10.177  
  10.178  (* (TableFun().key * string list) list option * int option
  10.179     -> Toplevel.transition -> Toplevel.transition *)
  10.180  fun nitpick_trans (opt_params, opt_subgoal) =
  10.181    Toplevel.keep (K ()
  10.182 -      o pick_nits (these opt_params) false (the_default 1 opt_subgoal)
  10.183 +      o snd o pick_nits (these opt_params) false (the_default 1 opt_subgoal)
  10.184        o Toplevel.proof_of)
  10.185  
  10.186  (* raw_param -> string *)
  10.187  fun string_for_raw_param (name, value) =
  10.188    name ^ " = " ^ stringify_raw_param_value value
  10.189  
  10.190 -(* bool -> Proof.state -> Proof.state *)
  10.191 -fun pick_nits_auto interactive state =
  10.192 -  let val thy = Proof.theory_of state in
  10.193 -    ((interactive andalso not (!Toplevel.quiet)
  10.194 -      andalso the (general_lookup_bool false (default_raw_params thy)
  10.195 -                  (SOME false) "auto"))
  10.196 -     ? pick_nits [] true 0) state
  10.197 -  end
  10.198 -
  10.199 -(* theory -> theory *)
  10.200 -fun register_auto thy =
  10.201 -  (not (is_registered_auto thy)
  10.202 -   ? (set_registered_auto
  10.203 -      #> Context.theory_map (Specification.add_theorem_hook pick_nits_auto)))
  10.204 -  thy
  10.205 -
  10.206  (* (TableFun().key * string) list option -> Toplevel.transition
  10.207     -> Toplevel.transition *)
  10.208  fun nitpick_params_trans opt_params =
  10.209    Toplevel.theory
  10.210 -      (fn thy =>
  10.211 -          let val thy = fold set_default_raw_param (these opt_params) thy in
  10.212 -            writeln ("Default parameters for Nitpick:\n" ^
  10.213 -                     (case rev (default_raw_params thy) of
  10.214 -                        [] => "none"
  10.215 -                      | params =>
  10.216 -                        (map check_raw_param params;
  10.217 -                         params |> map string_for_raw_param |> sort_strings
  10.218 -                                |> cat_lines)));
  10.219 -            register_auto thy
  10.220 -          end)
  10.221 +      (fold set_default_raw_param (these opt_params)
  10.222 +       #> tap (fn thy => 
  10.223 +                  writeln ("Default parameters for Nitpick:\n" ^
  10.224 +                           (case rev (default_raw_params thy) of
  10.225 +                              [] => "none"
  10.226 +                            | params =>
  10.227 +                              (map check_raw_param params;
  10.228 +                               params |> map string_for_raw_param
  10.229 +                                      |> sort_strings |> cat_lines)))))
  10.230  
  10.231  (* OuterParse.token list
  10.232     -> (Toplevel.transition -> Toplevel.transition) * OuterParse.token list *)
  10.233 -fun scan_nitpick_command tokens =
  10.234 -  (scan_params -- Scan.option OuterParse.nat) tokens |>> nitpick_trans
  10.235 -fun scan_nitpick_params_command tokens =
  10.236 -  scan_params tokens |>> nitpick_params_trans
  10.237 +val scan_nitpick_command =
  10.238 +  (scan_params -- Scan.option OuterParse.nat) #>> nitpick_trans
  10.239 +val scan_nitpick_params_command = scan_params #>> nitpick_params_trans
  10.240  
  10.241  val _ = OuterSyntax.improper_command "nitpick"
  10.242              "try to find a counterexample for a given subgoal using Kodkod"
  10.243 @@ -493,4 +469,10 @@
  10.244              "set and display the default parameters for Nitpick"
  10.245              OuterKeyword.thy_decl scan_nitpick_params_command
  10.246  
  10.247 +(* Proof.state -> bool * Proof.state *)
  10.248 +fun auto_nitpick state =
  10.249 +  if not (!auto) then (false, state) else pick_nits [] true 1 state
  10.250 +
  10.251 +val setup = Auto_Counterexample.register_tool ("nitpick", auto_nitpick)
  10.252 +
  10.253  end;
    11.1 --- a/src/HOL/Tools/Nitpick/nitpick_kodkod.ML	Thu Oct 29 11:26:47 2009 +0100
    11.2 +++ b/src/HOL/Tools/Nitpick/nitpick_kodkod.ML	Thu Oct 29 12:09:32 2009 +0100
    11.3 @@ -716,8 +716,8 @@
    11.4  (* extended_context -> kodkod_constrs -> nut NameTable.table -> dtype_spec list
    11.5     -> dtype_spec -> nfa_entry option *)
    11.6  fun nfa_entry_for_datatype _ _ _ _ ({co = true, ...} : dtype_spec) = NONE
    11.7 -  | nfa_entry_for_datatype ext_ctxt kk rel_table dtypes
    11.8 -                           ({typ, constrs, ...} : dtype_spec) =
    11.9 +  | nfa_entry_for_datatype _ _ _ _ {shallow = true, ...} = NONE
   11.10 +  | nfa_entry_for_datatype ext_ctxt kk rel_table dtypes {typ, constrs, ...} =
   11.11      SOME (typ, maps (nfa_transitions_for_constr ext_ctxt kk rel_table dtypes
   11.12                       o #const) constrs)
   11.13  
   11.14 @@ -884,12 +884,13 @@
   11.15  
   11.16  (* extended_context -> int Typtab.table -> kodkod_constrs -> nut NameTable.table
   11.17     -> dtype_spec -> Kodkod.formula list *)
   11.18 -fun other_axioms_for_datatype ext_ctxt ofs kk rel_table (dtype as {typ, ...}) =
   11.19 -  let val j0 = offset_of_type ofs typ in
   11.20 -    sel_axioms_for_datatype ext_ctxt j0 kk rel_table dtype @
   11.21 -    uniqueness_axioms_for_datatype ext_ctxt kk rel_table dtype @
   11.22 -    partition_axioms_for_datatype j0 kk rel_table dtype
   11.23 -  end
   11.24 +fun other_axioms_for_datatype _ _ _ _ {shallow = true, ...} = []
   11.25 +  | other_axioms_for_datatype ext_ctxt ofs kk rel_table (dtype as {typ, ...}) =
   11.26 +    let val j0 = offset_of_type ofs typ in
   11.27 +      sel_axioms_for_datatype ext_ctxt j0 kk rel_table dtype @
   11.28 +      uniqueness_axioms_for_datatype ext_ctxt kk rel_table dtype @
   11.29 +      partition_axioms_for_datatype j0 kk rel_table dtype
   11.30 +    end
   11.31  
   11.32  (* extended_context -> int Typtab.table -> kodkod_constrs -> nut NameTable.table
   11.33     -> dtype_spec list -> Kodkod.formula list *)
    12.1 --- a/src/HOL/Tools/Nitpick/nitpick_model.ML	Thu Oct 29 11:26:47 2009 +0100
    12.2 +++ b/src/HOL/Tools/Nitpick/nitpick_model.ML	Thu Oct 29 12:09:32 2009 +0100
    12.3 @@ -133,12 +133,14 @@
    12.4        | aux t = raise TERM ("Nitpick_Model.dest_plain_fun", [t])
    12.5    in apsnd (pairself rev) o aux end
    12.6  
    12.7 -(* typ -> term -> term list * term *)
    12.8 -fun break_in_two (Type ("*", [T1, T2]))
    12.9 -                 (Const (@{const_name Pair}, _) $ t1 $ t2) =
   12.10 -    break_in_two T2 t2 |>> cons t1
   12.11 -  | break_in_two _ (Const (@{const_name Pair}, _) $ t1 $ t2) = ([t1], t2)
   12.12 -  | break_in_two _ t = raise TERM ("Nitpick_Model.break_in_two", [t])
   12.13 +(* typ -> typ -> typ -> term -> term * term *)
   12.14 +fun break_in_two T T1 T2 t =
   12.15 +  let
   12.16 +    val ps = HOLogic.flat_tupleT_paths T
   12.17 +    val cut = length (HOLogic.strip_tupleT T1)
   12.18 +    val (ps1, ps2) = pairself HOLogic.flat_tupleT_paths (T1, T2)
   12.19 +    val (ts1, ts2) = t |> HOLogic.strip_ptuple ps |> chop cut
   12.20 +  in (HOLogic.mk_ptuple ps1 T1 ts1, HOLogic.mk_ptuple ps2 T2 ts2) end
   12.21  (* typ -> term -> term -> term *)
   12.22  fun pair_up (Type ("*", [T1', T2']))
   12.23              (t1 as Const (@{const_name Pair},
   12.24 @@ -153,12 +155,12 @@
   12.25  (* typ -> typ -> typ -> term -> term *)
   12.26  fun typecast_fun (Type ("fun", [T1', T2'])) T1 T2 t =
   12.27      let
   12.28 -      (* typ -> typ -> typ -> term -> term *)
   12.29 -      fun do_curry T1a T1b T2 t =
   12.30 +      (* typ -> typ -> typ -> typ -> term -> term *)
   12.31 +      fun do_curry T1 T1a T1b T2 t =
   12.32          let
   12.33            val (maybe_opt, ps) = dest_plain_fun t
   12.34            val ps =
   12.35 -            ps |>> map (break_in_two T1a #>> mk_flat_tuple T1a)
   12.36 +            ps |>> map (break_in_two T1 T1a T1b)
   12.37                 |> uncurry (map2 (fn (t1a, t1b) => fn t2 => (t1a, (t1b, t2))))
   12.38                 |> AList.coalesce (op =)
   12.39                 |> map (apsnd (make_plain_fun maybe_opt T1b T2))
   12.40 @@ -185,7 +187,7 @@
   12.41          case factor_out_types T1' T1 of
   12.42            ((_, NONE), (_, NONE)) => t |> do_arrow T1' T2' T1 T2
   12.43          | ((_, NONE), (T1a, SOME T1b)) =>
   12.44 -          t |> do_curry T1a T1b T2 |> do_arrow T1' T2' T1a (T1b --> T2)
   12.45 +          t |> do_curry T1 T1a T1b T2 |> do_arrow T1' T2' T1a (T1b --> T2)
   12.46          | ((T1a', SOME T1b'), (_, NONE)) =>
   12.47            t |> do_arrow T1a' (T1b' --> T2') T1 T2 |> do_uncurry T1' T2'
   12.48          | _ => raise TYPE ("Nitpick_Model.typecast_fun.do_fun", [T1, T1'], [])
   12.49 @@ -329,7 +331,8 @@
   12.50            HOLogic.mk_number nat_T j
   12.51          else case datatype_spec datatypes T of
   12.52            NONE => atom for_auto T j
   12.53 -        | SOME {constrs, co, ...} =>
   12.54 +        | SOME {shallow = true, ...} => atom for_auto T j
   12.55 +        | SOME {co, constrs, ...} =>
   12.56            let
   12.57              (* styp -> int list *)
   12.58              fun tuples_for_const (s, T) =
   12.59 @@ -600,11 +603,12 @@
   12.60      (* typ -> dtype_spec list *)
   12.61      fun integer_datatype T =
   12.62        [{typ = T, card = card_of_type card_assigns T, co = false,
   12.63 -        precise = false, constrs = []}]
   12.64 +        precise = false, shallow = false, constrs = []}]
   12.65        handle TYPE ("Nitpick_HOL.card_of_type", _, _) => []
   12.66      val (codatatypes, datatypes) =
   12.67 -      List.partition #co datatypes
   12.68 -      ||> append (integer_datatype nat_T @ integer_datatype int_T)
   12.69 +      datatypes |> filter_out #shallow
   12.70 +                |> List.partition #co
   12.71 +                ||> append (integer_datatype nat_T @ integer_datatype int_T)
   12.72      val block_of_datatypes =
   12.73        if show_datatypes andalso not (null datatypes) then
   12.74          [Pretty.big_list ("Datatype" ^ plural_s_for_list datatypes ^ ":")
    13.1 --- a/src/HOL/Tools/Nitpick/nitpick_nut.ML	Thu Oct 29 11:26:47 2009 +0100
    13.2 +++ b/src/HOL/Tools/Nitpick/nitpick_nut.ML	Thu Oct 29 12:09:32 2009 +0100
    13.3 @@ -749,8 +749,9 @@
    13.4             (~1 upto num_sels_for_constr_type T - 1)
    13.5  (* scope -> dtype_spec -> nut list * rep NameTable.table
    13.6     -> nut list * rep NameTable.table *)
    13.7 -fun choose_rep_for_sels_of_datatype scope ({constrs, ...} : dtype_spec) =
    13.8 -  fold_rev (choose_rep_for_sels_for_constr scope o #const) constrs
    13.9 +fun choose_rep_for_sels_of_datatype _ ({shallow = true, ...} : dtype_spec) = I
   13.10 +  | choose_rep_for_sels_of_datatype scope {constrs, ...} =
   13.11 +    fold_rev (choose_rep_for_sels_for_constr scope o #const) constrs
   13.12  (* scope -> rep NameTable.table -> nut list * rep NameTable.table *)
   13.13  fun choose_reps_for_all_sels (scope as {datatypes, ...}) =
   13.14    fold (choose_rep_for_sels_of_datatype scope) datatypes o pair []
    14.1 --- a/src/HOL/Tools/Nitpick/nitpick_scope.ML	Thu Oct 29 11:26:47 2009 +0100
    14.2 +++ b/src/HOL/Tools/Nitpick/nitpick_scope.ML	Thu Oct 29 12:09:32 2009 +0100
    14.3 @@ -22,6 +22,7 @@
    14.4      card: int,
    14.5      co: bool,
    14.6      precise: bool,
    14.7 +    shallow: bool,
    14.8      constrs: constr_spec list}
    14.9  
   14.10    type scope = {
   14.11 @@ -44,7 +45,7 @@
   14.12    val all_scopes :
   14.13      extended_context -> int -> (typ option * int list) list
   14.14      -> (styp option * int list) list -> (styp option * int list) list
   14.15 -    -> int list -> typ list -> typ list -> scope list
   14.16 +    -> int list -> typ list -> typ list -> typ list -> scope list
   14.17  end;
   14.18  
   14.19  structure Nitpick_Scope : NITPICK_SCOPE =
   14.20 @@ -66,6 +67,7 @@
   14.21    card: int,
   14.22    co: bool,
   14.23    precise: bool,
   14.24 +  shallow: bool,
   14.25    constrs: constr_spec list}
   14.26  
   14.27  type scope = {
   14.28 @@ -126,7 +128,7 @@
   14.29        card_assigns |> filter_out (equal @{typ bisim_iterator} o fst)
   14.30                     |> List.partition (is_fp_iterator_type o fst)
   14.31      val (unimportant_card_asgns, important_card_asgns) =
   14.32 -      card_asgns |> List.partition ((is_datatype thy orf is_integer_type) o fst)
   14.33 +      card_asgns |> List.partition ((is_integer_type orf is_datatype thy) o fst)
   14.34      val cards =
   14.35        map (fn (T, k) => quote (string_for_type ctxt T) ^ " = " ^
   14.36                          string_of_int k)
   14.37 @@ -431,10 +433,11 @@
   14.38       explicit_max = max, total = total} :: constrs
   14.39    end
   14.40  
   14.41 -(* extended_context -> scope_desc -> typ * int -> dtype_spec *)
   14.42 -fun datatype_spec_from_scope_descriptor (ext_ctxt as {thy, ...})
   14.43 +(* extended_context -> typ list -> scope_desc -> typ * int -> dtype_spec *)
   14.44 +fun datatype_spec_from_scope_descriptor (ext_ctxt as {thy, ...}) shallow_dataTs
   14.45                                          (desc as (card_asgns, _)) (T, card) =
   14.46    let
   14.47 +    val shallow = T mem shallow_dataTs
   14.48      val co = is_codatatype thy T
   14.49      val xs = boxed_datatype_constrs ext_ctxt T
   14.50      val self_recs = map (is_self_recursive_constr_type o snd) xs
   14.51 @@ -448,14 +451,18 @@
   14.52      val constrs =
   14.53        fold_rev (add_constr_spec desc co card sum_dom_cards num_self_recs
   14.54                                  num_non_self_recs) (self_recs ~~ xs) []
   14.55 -  in {typ = T, card = card, co = co, precise = precise, constrs = constrs} end
   14.56 +  in
   14.57 +    {typ = T, card = card, co = co, precise = precise, shallow = shallow,
   14.58 +     constrs = constrs}
   14.59 +  end
   14.60  
   14.61 -(* extended_context -> int -> scope_desc -> scope *)
   14.62 -fun scope_from_descriptor (ext_ctxt as {thy, ...}) sym_break
   14.63 +(* extended_context -> int -> typ list -> scope_desc -> scope *)
   14.64 +fun scope_from_descriptor (ext_ctxt as {thy, ...}) sym_break shallow_dataTs
   14.65                            (desc as (card_asgns, _)) =
   14.66    let
   14.67 -    val datatypes = map (datatype_spec_from_scope_descriptor ext_ctxt desc)
   14.68 -                        (filter (is_datatype thy o fst) card_asgns)
   14.69 +    val datatypes =
   14.70 +      map (datatype_spec_from_scope_descriptor ext_ctxt shallow_dataTs desc)
   14.71 +          (filter (is_datatype thy o fst) card_asgns)
   14.72      val bisim_depth = card_of_type card_asgns @{typ bisim_iterator} - 1
   14.73    in
   14.74      {ext_ctxt = ext_ctxt, card_assigns = card_asgns, datatypes = datatypes,
   14.75 @@ -480,9 +487,9 @@
   14.76  
   14.77  (* extended_context -> int -> (typ option * int list) list
   14.78     -> (styp option * int list) list -> (styp option * int list) list -> int list
   14.79 -   -> typ list -> typ list -> scope list *)
   14.80 +   -> typ list -> typ list -> typ list -> scope list *)
   14.81  fun all_scopes (ext_ctxt as {thy, ctxt, ...}) sym_break cards_asgns maxes_asgns
   14.82 -               iters_asgns bisim_depths mono_Ts nonmono_Ts =
   14.83 +               iters_asgns bisim_depths mono_Ts nonmono_Ts shallow_dataTs =
   14.84    let
   14.85      val cards_asgns = fix_cards_assigns_wrt_boxing thy mono_Ts cards_asgns
   14.86      val blocks = blocks_for_types ctxt cards_asgns maxes_asgns iters_asgns
   14.87 @@ -492,7 +499,7 @@
   14.88                  |> map_filter (scope_descriptor_from_combination thy blocks)
   14.89    in
   14.90      descs |> length descs <= distinct_threshold ? distinct (op =)
   14.91 -          |> map (scope_from_descriptor ext_ctxt sym_break)
   14.92 +          |> map (scope_from_descriptor ext_ctxt sym_break shallow_dataTs)
   14.93    end
   14.94  
   14.95  end;
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/Tools/Auto_Counterexample.thy	Thu Oct 29 12:09:32 2009 +0100
    15.3 @@ -0,0 +1,15 @@
    15.4 +(*  Title:   Tools/Auto_Counterexample.thy
    15.5 +    Author:  Jasmin Blanchette, TU Muenchen
    15.6 +
    15.7 +Counterexample Search Unit (do not abbreviate!).
    15.8 +*)
    15.9 +
   15.10 +header {* Counterexample Search Unit *}
   15.11 +
   15.12 +theory Auto_Counterexample
   15.13 +imports Pure
   15.14 +uses
   15.15 +  "~~/src/Tools/auto_counterexample.ML"
   15.16 +begin
   15.17 +
   15.18 +end
    16.1 --- a/src/Tools/Code_Generator.thy	Thu Oct 29 11:26:47 2009 +0100
    16.2 +++ b/src/Tools/Code_Generator.thy	Thu Oct 29 12:09:32 2009 +0100
    16.3 @@ -5,7 +5,7 @@
    16.4  header {* Loading the code generator modules *}
    16.5  
    16.6  theory Code_Generator
    16.7 -imports Pure
    16.8 +imports Auto_Counterexample
    16.9  uses
   16.10    "~~/src/Tools/value.ML"
   16.11    "~~/src/Tools/quickcheck.ML"
   16.12 @@ -25,4 +25,4 @@
   16.13    #> Nbe.setup
   16.14  *}
   16.15  
   16.16 -end
   16.17 \ No newline at end of file
   16.18 +end
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/Tools/auto_counterexample.ML	Thu Oct 29 12:09:32 2009 +0100
    17.3 @@ -0,0 +1,59 @@
    17.4 +(*  Title:      Tools/auto_counterexample.ML
    17.5 +    Author:     Jasmin Blanchette, TU Muenchen
    17.6 +
    17.7 +Counterexample Search Unit (do not abbreviate!).
    17.8 +*)
    17.9 +
   17.10 +signature AUTO_COUNTEREXAMPLE =
   17.11 +sig
   17.12 +  val time_limit: int Unsynchronized.ref
   17.13 +
   17.14 +  val register_tool :
   17.15 +    string * (Proof.state -> bool * Proof.state) -> theory -> theory
   17.16 +end;
   17.17 +
   17.18 +structure Auto_Counterexample : AUTO_COUNTEREXAMPLE =
   17.19 +struct
   17.20 +
   17.21 +(* preferences *)
   17.22 +
   17.23 +val time_limit = Unsynchronized.ref 2500
   17.24 +
   17.25 +val _ =
   17.26 +  ProofGeneralPgip.add_preference Preferences.category_tracing
   17.27 +    (Preferences.nat_pref time_limit
   17.28 +      "auto-counterexample-time-limit"
   17.29 +      "Time limit for automatic counterexample search (in milliseconds).")
   17.30 +
   17.31 +
   17.32 +(* configuration *)
   17.33 +
   17.34 +structure Data = TheoryDataFun(
   17.35 +  type T = (string * (Proof.state -> bool * Proof.state)) list
   17.36 +  val empty = []
   17.37 +  val copy = I
   17.38 +  val extend = I
   17.39 +  fun merge _ (tools1, tools2) = AList.merge (op =) (K true) (tools1, tools2)
   17.40 +)
   17.41 +
   17.42 +val register_tool = Data.map o AList.update (op =)
   17.43 +
   17.44 +
   17.45 +(* automatic testing *)
   17.46 +
   17.47 +val _ = Context.>> (Specification.add_theorem_hook (fn interact => fn state =>
   17.48 +  case !time_limit of
   17.49 +    0 => state
   17.50 +  | ms =>
   17.51 +    TimeLimit.timeLimit (Time.fromMilliseconds ms)
   17.52 +        (fn () =>
   17.53 +            if interact andalso not (!Toplevel.quiet) then
   17.54 +              fold_rev (fn (_, tool) => fn (true, state) => (true, state)
   17.55 +                                         | (false, state) => tool state)
   17.56 +                   (Data.get (Proof.theory_of state)) (false, state) |> snd
   17.57 +            else
   17.58 +              state) ()
   17.59 +    handle TimeLimit.TimeOut =>
   17.60 +           (warning "Automatic counterexample search timed out."; state)))
   17.61 +
   17.62 +end;
    18.1 --- a/src/Tools/quickcheck.ML	Thu Oct 29 11:26:47 2009 +0100
    18.2 +++ b/src/Tools/quickcheck.ML	Thu Oct 29 12:09:32 2009 +0100
    18.3 @@ -7,10 +7,10 @@
    18.4  signature QUICKCHECK =
    18.5  sig
    18.6    val auto: bool Unsynchronized.ref
    18.7 -  val auto_time_limit: int Unsynchronized.ref
    18.8    val test_term: Proof.context -> bool -> string option -> int -> int -> term ->
    18.9      (string * term) list option
   18.10    val add_generator: string * (Proof.context -> term -> int -> term list option) -> theory -> theory
   18.11 +  val setup: theory -> theory
   18.12    val quickcheck: (string * string) list -> int -> Proof.state -> (string * term) list option
   18.13  end;
   18.14  
   18.15 @@ -20,20 +20,13 @@
   18.16  (* preferences *)
   18.17  
   18.18  val auto = Unsynchronized.ref false;
   18.19 -val auto_time_limit = Unsynchronized.ref 2500;
   18.20  
   18.21  val _ =
   18.22    ProofGeneralPgip.add_preference Preferences.category_tracing
   18.23    (setmp_CRITICAL auto true (fn () =>
   18.24      Preferences.bool_pref auto
   18.25        "auto-quickcheck"
   18.26 -      "Whether to enable quickcheck automatically.") ());
   18.27 -
   18.28 -val _ =
   18.29 -  ProofGeneralPgip.add_preference Preferences.category_tracing
   18.30 -    (Preferences.nat_pref auto_time_limit
   18.31 -      "auto-quickcheck-time-limit"
   18.32 -      "Time limit for automatic quickcheck (in milliseconds).");
   18.33 +      "Whether to run Quickcheck automatically.") ());
   18.34  
   18.35  
   18.36  (* quickcheck configuration -- default parameters, test generators *)
   18.37 @@ -159,28 +152,26 @@
   18.38  
   18.39  (* automatic testing *)
   18.40  
   18.41 -val _ = Context.>> (Specification.add_theorem_hook (fn int => fn state =>
   18.42 -  let
   18.43 -    val ctxt = Proof.context_of state;
   18.44 -    val assms = map term_of (Assumption.all_assms_of ctxt);
   18.45 -    val Test_Params { size, iterations, default_type } =
   18.46 -      (snd o Data.get o Proof.theory_of) state;
   18.47 -    fun test () =
   18.48 -      let
   18.49 -        val res = TimeLimit.timeLimit (Time.fromMilliseconds (!auto_time_limit))
   18.50 -          (try (test_goal true NONE size iterations default_type [] 1 assms)) state;
   18.51 -      in
   18.52 -        case res of
   18.53 -          NONE => state
   18.54 -        | SOME NONE => state
   18.55 -        | SOME cex => Proof.goal_message (fn () => Pretty.chunks [Pretty.str "",
   18.56 -            Pretty.mark Markup.hilite (pretty_counterex ctxt cex)]) state
   18.57 -      end handle TimeLimit.TimeOut => (warning "Auto quickcheck: timeout."; state);
   18.58 -  in
   18.59 -    if int andalso !auto andalso not (!Toplevel.quiet)
   18.60 -    then test ()
   18.61 -    else state
   18.62 -  end));
   18.63 +fun auto_quickcheck state =
   18.64 +  if not (!auto) then
   18.65 +    (false, state)
   18.66 +  else
   18.67 +    let
   18.68 +      val ctxt = Proof.context_of state;
   18.69 +      val assms = map term_of (Assumption.all_assms_of ctxt);
   18.70 +      val Test_Params { size, iterations, default_type } =
   18.71 +        (snd o Data.get o Proof.theory_of) state;
   18.72 +      val res =
   18.73 +        try (test_goal true NONE size iterations default_type [] 1 assms) state;
   18.74 +    in
   18.75 +      case res of
   18.76 +        NONE => (false, state)
   18.77 +      | SOME NONE => (false, state)
   18.78 +      | SOME cex => (true, Proof.goal_message (K (Pretty.chunks [Pretty.str "",
   18.79 +          Pretty.mark Markup.hilite (pretty_counterex ctxt cex)])) state)
   18.80 +    end
   18.81 +
   18.82 +val setup = Auto_Counterexample.register_tool ("quickcheck", auto_quickcheck)
   18.83  
   18.84  
   18.85  (* Isar commands *)
   18.86 @@ -251,4 +242,3 @@
   18.87  
   18.88  
   18.89  val auto_quickcheck = Quickcheck.auto;
   18.90 -val auto_quickcheck_time_limit = Quickcheck.auto_time_limit;