src/HOL/Inductive.thy
author haftmann
Mon Aug 14 13:46:06 2006 +0200 (2006-08-14)
changeset 20380 14f9f2a1caa6
parent 19599 a5c7eb37d14f
child 20604 9dba9c7872c9
permissions -rw-r--r--
simplified code generator setup
     1 (*  Title:      HOL/Inductive.thy
     2     ID:         $Id$
     3     Author:     Markus Wenzel, TU Muenchen
     4 *)
     5 
     6 header {* Support for inductive sets and types *}
     7 
     8 theory Inductive 
     9 imports FixedPoint Sum_Type Relation Record
    10 uses
    11   ("Tools/inductive_package.ML")
    12   ("Tools/inductive_realizer.ML")
    13   ("Tools/inductive_codegen.ML")
    14   ("Tools/datatype_aux.ML")
    15   ("Tools/datatype_prop.ML")
    16   ("Tools/datatype_rep_proofs.ML")
    17   ("Tools/datatype_abs_proofs.ML")
    18   ("Tools/datatype_realizer.ML")
    19   ("Tools/datatype_hooks.ML")
    20   ("Tools/datatype_package.ML")
    21   ("Tools/datatype_codegen.ML")
    22   ("Tools/recfun_codegen.ML")
    23   ("Tools/primrec_package.ML")
    24 begin
    25 
    26 subsection {* Inductive sets *}
    27 
    28 text {* Inversion of injective functions. *}
    29 
    30 constdefs
    31   myinv :: "('a => 'b) => ('b => 'a)"
    32   "myinv (f :: 'a => 'b) == \<lambda>y. THE x. f x = y"
    33 
    34 lemma myinv_f_f: "inj f ==> myinv f (f x) = x"
    35 proof -
    36   assume "inj f"
    37   hence "(THE x'. f x' = f x) = (THE x'. x' = x)"
    38     by (simp only: inj_eq)
    39   also have "... = x" by (rule the_eq_trivial)
    40   finally show ?thesis by (unfold myinv_def)
    41 qed
    42 
    43 lemma f_myinv_f: "inj f ==> y \<in> range f ==> f (myinv f y) = y"
    44 proof (unfold myinv_def)
    45   assume inj: "inj f"
    46   assume "y \<in> range f"
    47   then obtain x where "y = f x" ..
    48   hence x: "f x = y" ..
    49   thus "f (THE x. f x = y) = y"
    50   proof (rule theI)
    51     fix x' assume "f x' = y"
    52     with x have "f x' = f x" by simp
    53     with inj show "x' = x" by (rule injD)
    54   qed
    55 qed
    56 
    57 hide const myinv
    58 
    59 
    60 text {* Package setup. *}
    61 
    62 use "Tools/inductive_package.ML"
    63 setup InductivePackage.setup
    64 
    65 theorems basic_monos [mono] =
    66   subset_refl imp_refl disj_mono conj_mono ex_mono all_mono if_def2
    67   Collect_mono in_mono vimage_mono
    68   imp_conv_disj not_not de_Morgan_disj de_Morgan_conj
    69   not_all not_ex
    70   Ball_def Bex_def
    71   induct_rulify_fallback
    72 
    73 
    74 subsection {* Inductive datatypes and primitive recursion *}
    75 
    76 text {* Package setup. *}
    77 
    78 use "Tools/recfun_codegen.ML"
    79 setup RecfunCodegen.setup
    80 
    81 use "Tools/datatype_aux.ML"
    82 use "Tools/datatype_prop.ML"
    83 use "Tools/datatype_rep_proofs.ML"
    84 use "Tools/datatype_abs_proofs.ML"
    85 use "Tools/datatype_realizer.ML"
    86 
    87 use "Tools/datatype_hooks.ML"
    88 setup DatatypeHooks.setup
    89 
    90 use "Tools/datatype_package.ML"
    91 setup DatatypePackage.setup
    92 
    93 use "Tools/datatype_codegen.ML"
    94 setup DatatypeCodegen.setup
    95 
    96 use "Tools/inductive_realizer.ML"
    97 setup InductiveRealizer.setup
    98 
    99 use "Tools/inductive_codegen.ML"
   100 setup InductiveCodegen.setup
   101 
   102 use "Tools/primrec_package.ML"
   103 
   104 end