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