src/HOL/Code_Generator.thy
changeset 22423 c1836b14c63a
parent 22385 cc2be3315e72
child 22473 753123c89d72
equal deleted inserted replaced
22422:ee19cdb07528 22423:c1836b14c63a
    85 
    85 
    86 code_const "op ="
    86 code_const "op ="
    87   (Haskell infixl 4 "==")
    87   (Haskell infixl 4 "==")
    88 
    88 
    89 
    89 
    90 text {* boolean expressions *}
    90 text {* type bool *}
       
    91 
       
    92 code_datatype True False
    91 
    93 
    92 lemma [code func]:
    94 lemma [code func]:
    93   shows "(False \<and> x) = False"
    95   shows "(False \<and> x) = False"
    94     and "(True \<and> x) = x"
    96     and "(True \<and> x) = x"
    95     and "(x \<and> False) = False"
    97     and "(x \<and> False) = False"
   150 
   152 
   151 code_reserved OCaml
   153 code_reserved OCaml
   152   bool true false not
   154   bool true false not
   153 
   155 
   154 
   156 
   155 text {* itself as a code generator datatype *}
   157 text {* type prop *}
   156 
   158 
   157 setup {*
   159 code_datatype Trueprop "prop"
   158   let
   160 
   159     val v = ("'a", []);
   161 
   160     val t = Logic.mk_type (TFree v);
   162 text {* type itself *}
   161     val Const (c, ty) = t;
   163 
   162     val (_, Type (dtco, _)) = strip_type ty;
   164 code_datatype "TYPE('a)"
   163   in
   165 
   164     CodegenData.add_datatype (dtco, (([v], [(c, [])]), CodegenData.lazy (fn () => [])))
   166 
   165   end
   167 text {* prevent unfolding of quantifier definitions *}
   166 *} 
   168 
       
   169 lemma [code func]:
       
   170   "Ex = Ex"
       
   171   "All = All"
       
   172   by rule+
   167 
   173 
   168 
   174 
   169 text {* code generation for arbitrary as exception *}
   175 text {* code generation for arbitrary as exception *}
   170 
   176 
   171 setup {*
   177 setup {*