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