src/HOL/Main.thy
author nipkow
Wed Aug 18 11:09:40 2004 +0200 (2004-08-18)
changeset 15140 322485b816ac
parent 15131 c69542757a4d
child 15151 429666b09783
permissions -rw-r--r--
import -> imports
     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 Map Infinite_Set Extraction Refute
    10 begin
    11 
    12 text {*
    13   Theory @{text Main} includes everything.  Note that theory @{text
    14   PreList} already includes most HOL theories.
    15 *}
    16 
    17 subsection {* Configuration of the code generator *}
    18 
    19 types_code
    20   "bool"  ("bool")
    21   "*"     ("(_ */ _)")
    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   "Pair"    ("(_,/ _)")
    32   "fst"     ("fst")
    33   "snd"     ("snd")
    34 
    35   "wfrec"   ("wf'_rec?")
    36 
    37 quickcheck_params [default_type = int]
    38 
    39 ML {*
    40 fun wf_rec f x = f (wf_rec f) x;
    41 
    42 fun term_of_bool b = if b then HOLogic.true_const else HOLogic.false_const;
    43 val term_of_int = HOLogic.mk_int;
    44 fun term_of_id_42 f T g U (x, y) = HOLogic.pair_const T U $ f x $ g y;
    45 fun term_of_fun_type _ T _ U _ = Free ("<function>", T --> U);
    46 
    47 val eq_codegen_setup = [Codegen.add_codegen "eq_codegen"
    48   (fn thy => fn gr => fn dep => fn b => fn t =>
    49     (case strip_comb t of
    50        (Const ("op =", Type (_, [Type ("fun", _), _])), _) => None
    51      | (Const ("op =", _), [t, u]) =>
    52           let
    53             val (gr', pt) = Codegen.invoke_codegen thy dep false (gr, t);
    54             val (gr'', pu) = Codegen.invoke_codegen thy dep false (gr', u)
    55           in
    56             Some (gr'', Codegen.parens
    57               (Pretty.block [pt, Pretty.str " =", Pretty.brk 1, pu]))
    58           end
    59      | (t as Const ("op =", _), ts) => Some (Codegen.invoke_codegen
    60          thy dep b (gr, Codegen.eta_expand t ts 2))
    61      | _ => None))];
    62 
    63 fun gen_bool i = one_of [false, true];
    64 
    65 fun gen_int i = one_of [~1, 1] * random_range 0 i;
    66 
    67 fun gen_id_42 aG bG i = (aG i, bG i);
    68 
    69 fun gen_fun_type _ G i =
    70   let
    71     val f = ref (fn x => raise ERROR);
    72     val _ = (f := (fn x =>
    73       let
    74         val y = G i;
    75         val f' = !f
    76       in (f := (fn x' => if x = x' then y else f' x'); y) end))
    77   in (fn x => !f x) end;
    78 *}
    79 
    80 setup eq_codegen_setup
    81 
    82 lemma [code]: "((n::nat) < 0) = False" by simp
    83 lemma [code]: "(0 < Suc n) = True" by simp
    84 lemmas [code] = Suc_less_eq imp_conv_disj
    85 
    86 subsection {* Configuration of the 'refute' command *}
    87 
    88 text {*
    89   The following are fairly reasonable default values.  For an
    90   explanation of these parameters, see 'HOL/Refute.thy'.
    91 *}
    92 
    93 refute_params [minsize=1,
    94                maxsize=8,
    95                maxvars=10000,
    96                maxtime=60,
    97                satsolver="auto"]
    98 
    99 end