src/HOL/Main.thy
author berghofe
Fri Jul 01 13:56:34 2005 +0200 (2005-07-01)
changeset 16635 bf7de5723c60
parent 16587 b34c8aa657a5
child 16770 1f1b1fae30e4
permissions -rw-r--r--
Moved some code lemmas from Main to Nat.
     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 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   "HOL.If"      ("(if _/ then _/ else _)")
    30 
    31   "wfrec"   ("wf'_rec?")
    32 
    33 quickcheck_params [default_type = int]
    34 
    35 (*FIXME: the IntInf.fromInt below hides a dependence on fixed-precision ints!*)
    36 ML {*
    37 fun wf_rec f x = f (wf_rec f) x;
    38 
    39 fun term_of_bool b = if b then HOLogic.true_const else HOLogic.false_const;
    40 val term_of_int = HOLogic.mk_int o IntInf.fromInt;
    41 fun term_of_fun_type _ T _ U _ = Free ("<function>", T --> U);
    42 
    43 local
    44 
    45 fun eq_codegen thy defs gr dep thyname b t =
    46     (case strip_comb t of
    47        (Const ("op =", Type (_, [Type ("fun", _), _])), _) => NONE
    48      | (Const ("op =", _), [t, u]) =>
    49           let
    50             val (gr', pt) = Codegen.invoke_codegen thy defs dep thyname false (gr, t);
    51             val (gr'', pu) = Codegen.invoke_codegen thy defs dep thyname false (gr', u)
    52           in
    53             SOME (gr'', Codegen.parens
    54               (Pretty.block [pt, Pretty.str " =", Pretty.brk 1, pu]))
    55           end
    56      | (t as Const ("op =", _), ts) => SOME (Codegen.invoke_codegen
    57          thy defs dep thyname b (gr, Codegen.eta_expand t ts 2))
    58      | _ => NONE);
    59 
    60 in
    61 
    62 val eq_codegen_setup = [Codegen.add_codegen "eq_codegen" eq_codegen];
    63 
    64 end;
    65 
    66 fun gen_bool i = one_of [false, true];
    67 
    68 fun gen_int i = one_of [~1, 1] * random_range 0 i;
    69 
    70 fun gen_fun_type _ G i =
    71   let
    72     val f = ref (fn x => raise ERROR);
    73     val _ = (f := (fn x =>
    74       let
    75         val y = G i;
    76         val f' = !f
    77       in (f := (fn x' => if x = x' then y else f' x'); y) end))
    78   in (fn x => !f x) end;
    79 *}
    80 
    81 setup eq_codegen_setup
    82 
    83 lemmas [code] = imp_conv_disj
    84 
    85 subsection {* Configuration of the 'refute' command *}
    86 
    87 text {*
    88   The following are fairly reasonable default values.  For an
    89   explanation of these parameters, see 'HOL/Refute.thy'.
    90 *}
    91 
    92 refute_params ["itself"=1,
    93                minsize=1,
    94                maxsize=8,
    95                maxvars=10000,
    96                maxtime=60,
    97                satsolver="auto"]
    98 
    99 end