src/HOL/Main.thy
author webertj
Mon Mar 07 19:30:53 2005 +0100 (2005-03-07)
changeset 15584 3478bb4f93ff
parent 15531 08c8dad8e399
child 15872 8336ff711d80
permissions -rw-r--r--
refute_params: default value itself=1 added (for type classes)
     1 (*  Title:      HOL/Main.thy
     2     ID:         $Id$
     3     Author:     Stefan Berghofer, Tobias Nipkow, Tjark Weber, Markus Wenzel (TU Muenchen)
     4 *)
     5 
     6 header {* Main HOL *}
     7 
     8 theory Main
     9     imports Extraction Refute Reconstruction
    10 
    11 begin
    12 
    13 text {*
    14   Theory @{text Main} includes everything.  Note that theory @{text
    15   PreList} already includes most HOL theories.
    16 *}
    17 
    18 subsection {* Configuration of the code generator *}
    19 
    20 types_code
    21   "bool"  ("bool")
    22 
    23 consts_code
    24   "True"    ("true")
    25   "False"   ("false")
    26   "Not"     ("not")
    27   "op |"    ("(_ orelse/ _)")
    28   "op &"    ("(_ andalso/ _)")
    29   "If"      ("(if _/ then _/ else _)")
    30 
    31   "wfrec"   ("wf'_rec?")
    32 
    33 quickcheck_params [default_type = int]
    34 
    35 ML {*
    36 fun wf_rec f x = f (wf_rec f) x;
    37 
    38 fun term_of_bool b = if b then HOLogic.true_const else HOLogic.false_const;
    39 val term_of_int = HOLogic.mk_int;
    40 fun term_of_fun_type _ T _ U _ = Free ("<function>", T --> U);
    41 
    42 val eq_codegen_setup = [Codegen.add_codegen "eq_codegen"
    43   (fn thy => fn gr => fn dep => fn b => fn t =>
    44     (case strip_comb t of
    45        (Const ("op =", Type (_, [Type ("fun", _), _])), _) => NONE
    46      | (Const ("op =", _), [t, u]) =>
    47           let
    48             val (gr', pt) = Codegen.invoke_codegen thy dep false (gr, t);
    49             val (gr'', pu) = Codegen.invoke_codegen thy dep false (gr', u)
    50           in
    51             SOME (gr'', Codegen.parens
    52               (Pretty.block [pt, Pretty.str " =", Pretty.brk 1, pu]))
    53           end
    54      | (t as Const ("op =", _), ts) => SOME (Codegen.invoke_codegen
    55          thy dep b (gr, Codegen.eta_expand t ts 2))
    56      | _ => NONE))];
    57 
    58 fun gen_bool i = one_of [false, true];
    59 
    60 fun gen_int i = one_of [~1, 1] * random_range 0 i;
    61 
    62 fun gen_fun_type _ G i =
    63   let
    64     val f = ref (fn x => raise ERROR);
    65     val _ = (f := (fn x =>
    66       let
    67         val y = G i;
    68         val f' = !f
    69       in (f := (fn x' => if x = x' then y else f' x'); y) end))
    70   in (fn x => !f x) end;
    71 *}
    72 
    73 setup eq_codegen_setup
    74 
    75 lemma [code]: "((n::nat) < 0) = False" by simp
    76 lemma [code]: "(0 < Suc n) = True" by simp
    77 lemmas [code] = Suc_less_eq imp_conv_disj
    78 
    79 subsection {* Configuration of the 'refute' command *}
    80 
    81 text {*
    82   The following are fairly reasonable default values.  For an
    83   explanation of these parameters, see 'HOL/Refute.thy'.
    84 *}
    85 
    86 refute_params ["itself"=1,
    87                minsize=1,
    88                maxsize=8,
    89                maxvars=10000,
    90                maxtime=60,
    91                satsolver="auto"]
    92 
    93 end