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