src/HOL/Inductive.thy
author nipkow
Wed Aug 18 11:09:40 2004 +0200 (2004-08-18)
changeset 15140 322485b816ac
parent 15131 c69542757a4d
child 16417 9bc16273c2d4
permissions -rw-r--r--
import -> imports
     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 Gfp Sum_Type Relation Record
    10 files
    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_package.ML")
    20   ("Tools/datatype_codegen.ML")
    21   ("Tools/recfun_codegen.ML")
    22   ("Tools/primrec_package.ML")
    23 begin
    24 
    25 subsection {* Inductive sets *}
    26 
    27 text {* Inversion of injective functions. *}
    28 
    29 constdefs
    30   myinv :: "('a => 'b) => ('b => 'a)"
    31   "myinv (f :: 'a => 'b) == \<lambda>y. THE x. f x = y"
    32 
    33 lemma myinv_f_f: "inj f ==> myinv f (f x) = x"
    34 proof -
    35   assume "inj f"
    36   hence "(THE x'. f x' = f x) = (THE x'. x' = x)"
    37     by (simp only: inj_eq)
    38   also have "... = x" by (rule the_eq_trivial)
    39   finally show ?thesis by (unfold myinv_def)
    40 qed
    41 
    42 lemma f_myinv_f: "inj f ==> y \<in> range f ==> f (myinv f y) = y"
    43 proof (unfold myinv_def)
    44   assume inj: "inj f"
    45   assume "y \<in> range f"
    46   then obtain x where "y = f x" ..
    47   hence x: "f x = y" ..
    48   thus "f (THE x. f x = y) = y"
    49   proof (rule theI)
    50     fix x' assume "f x' = y"
    51     with x have "f x' = f x" by simp
    52     with inj show "x' = x" by (rule injD)
    53   qed
    54 qed
    55 
    56 hide const myinv
    57 
    58 
    59 text {* Package setup. *}
    60 
    61 use "Tools/inductive_package.ML"
    62 setup InductivePackage.setup
    63 
    64 theorems basic_monos [mono] =
    65   subset_refl imp_refl disj_mono conj_mono ex_mono all_mono if_def2
    66   Collect_mono in_mono vimage_mono
    67   imp_conv_disj not_not de_Morgan_disj de_Morgan_conj
    68   not_all not_ex
    69   Ball_def Bex_def
    70   induct_rulify2
    71 
    72 
    73 subsection {* Inductive datatypes and primitive recursion *}
    74 
    75 text {* Package setup. *}
    76 
    77 use "Tools/recfun_codegen.ML"
    78 setup RecfunCodegen.setup
    79 
    80 use "Tools/datatype_aux.ML"
    81 use "Tools/datatype_prop.ML"
    82 use "Tools/datatype_rep_proofs.ML"
    83 use "Tools/datatype_abs_proofs.ML"
    84 use "Tools/datatype_realizer.ML"
    85 use "Tools/datatype_package.ML"
    86 setup DatatypePackage.setup
    87 
    88 use "Tools/datatype_codegen.ML"
    89 setup DatatypeCodegen.setup
    90 
    91 use "Tools/inductive_realizer.ML"
    92 setup InductiveRealizer.setup
    93 
    94 use "Tools/inductive_codegen.ML"
    95 setup InductiveCodegen.setup
    96 
    97 use "Tools/primrec_package.ML"
    98 
    99 end