src/HOL/subset.thy
author oheimb
Wed Jan 31 10:15:55 2001 +0100 (2001-01-31)
changeset 11008 f7333f055ef6
parent 10291 a88d347db404
child 11083 d8fda557e476
permissions -rw-r--r--
improved theory reference in comment
clasohm@1475
     1
(*  Title:      HOL/subset.thy
clasohm@923
     2
    ID:         $Id$
clasohm@1475
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1994  University of Cambridge
wenzelm@10276
     5
wenzelm@10276
     6
Subset lemmas and HOL type definitions.
clasohm@923
     7
*)
clasohm@923
     8
wenzelm@7705
     9
theory subset = Set
wenzelm@10276
    10
files "Tools/induct_attrib.ML" ("Tools/typedef_package.ML"):
wenzelm@7705
    11
wenzelm@9895
    12
(*belongs to theory Ord*)
wenzelm@9895
    13
theorems linorder_cases [case_names less equal greater] =
wenzelm@9895
    14
  linorder_less_split
wenzelm@9895
    15
wenzelm@9895
    16
(*belongs to theory Set*)
wenzelm@9895
    17
setup Rulify.setup
berghofe@7717
    18
wenzelm@10276
    19
wenzelm@10276
    20
section {* HOL type definitions *}
wenzelm@10276
    21
wenzelm@10276
    22
constdefs
wenzelm@10276
    23
  type_definition :: "('a => 'b) => ('b => 'a) => 'b set => bool"
wenzelm@10276
    24
  "type_definition Rep Abs A ==
wenzelm@10276
    25
    (\<forall>x. Rep x \<in> A) \<and>
wenzelm@10276
    26
    (\<forall>x. Abs (Rep x) = x) \<and>
wenzelm@10276
    27
    (\<forall>y \<in> A. Rep (Abs y) = y)"
wenzelm@10276
    28
  -- {* This will be stated as an axiom for each typedef! *}
wenzelm@10276
    29
wenzelm@10290
    30
lemma type_definitionI [intro]:
wenzelm@10291
    31
  "(!!x. Rep x \<in> A) ==>
wenzelm@10291
    32
    (!!x. Abs (Rep x) = x) ==>
wenzelm@10291
    33
    (!!y. y \<in> A ==> Rep (Abs y) = y) ==>
wenzelm@10290
    34
    type_definition Rep Abs A"
wenzelm@10290
    35
  by (unfold type_definition_def) blast
wenzelm@10290
    36
wenzelm@10276
    37
theorem Rep: "type_definition Rep Abs A ==> Rep x \<in> A"
wenzelm@10276
    38
  by (unfold type_definition_def) blast
wenzelm@10276
    39
wenzelm@10276
    40
theorem Rep_inverse: "type_definition Rep Abs A ==> Abs (Rep x) = x"
wenzelm@10276
    41
  by (unfold type_definition_def) blast
wenzelm@10276
    42
wenzelm@10276
    43
theorem Abs_inverse: "type_definition Rep Abs A ==> y \<in> A ==> Rep (Abs y) = y"
wenzelm@10276
    44
  by (unfold type_definition_def) blast
wenzelm@10276
    45
wenzelm@10276
    46
theorem Rep_inject: "type_definition Rep Abs A ==> (Rep x = Rep y) = (x = y)"
wenzelm@10276
    47
proof -
wenzelm@10276
    48
  assume tydef: "type_definition Rep Abs A"
wenzelm@10276
    49
  show ?thesis
wenzelm@10276
    50
  proof
wenzelm@10276
    51
    assume "Rep x = Rep y"
wenzelm@10276
    52
    hence "Abs (Rep x) = Abs (Rep y)" by (simp only:)
wenzelm@10276
    53
    thus "x = y" by (simp only: Rep_inverse [OF tydef])
wenzelm@10276
    54
  next
wenzelm@10276
    55
    assume "x = y"
wenzelm@10276
    56
    thus "Rep x = Rep y" by simp
wenzelm@10276
    57
  qed
wenzelm@10276
    58
qed
wenzelm@10276
    59
wenzelm@10284
    60
theorem Abs_inject:
wenzelm@10284
    61
  "type_definition Rep Abs A ==> x \<in> A ==> y \<in> A ==> (Abs x = Abs y) = (x = y)"
wenzelm@10284
    62
proof -
wenzelm@10284
    63
  assume tydef: "type_definition Rep Abs A"
wenzelm@10284
    64
  assume x: "x \<in> A" and y: "y \<in> A"
wenzelm@10284
    65
  show ?thesis
wenzelm@10284
    66
  proof
wenzelm@10284
    67
    assume "Abs x = Abs y"
wenzelm@10284
    68
    hence "Rep (Abs x) = Rep (Abs y)" by simp
wenzelm@10284
    69
    moreover note x hence "Rep (Abs x) = x" by (rule Abs_inverse [OF tydef])
wenzelm@10284
    70
    moreover note y hence "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
wenzelm@10284
    71
    ultimately show "x = y" by (simp only:)
wenzelm@10284
    72
  next
wenzelm@10284
    73
    assume "x = y"
wenzelm@10284
    74
    thus "Abs x = Abs y" by simp
wenzelm@10284
    75
  qed
wenzelm@10284
    76
qed
wenzelm@10284
    77
wenzelm@10276
    78
theorem Rep_cases:
wenzelm@10276
    79
  "type_definition Rep Abs A ==> y \<in> A ==> (!!x. y = Rep x ==> P) ==> P"
wenzelm@10276
    80
proof -
wenzelm@10276
    81
  assume tydef: "type_definition Rep Abs A"
wenzelm@10276
    82
  assume y: "y \<in> A" and r: "(!!x. y = Rep x ==> P)"
wenzelm@10276
    83
  show P
wenzelm@10276
    84
  proof (rule r)
wenzelm@10276
    85
    from y have "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
wenzelm@10276
    86
    thus "y = Rep (Abs y)" ..
wenzelm@10276
    87
  qed
wenzelm@10276
    88
qed
wenzelm@10276
    89
wenzelm@10276
    90
theorem Abs_cases:
wenzelm@10276
    91
  "type_definition Rep Abs A ==> (!!y. x = Abs y ==> y \<in> A ==> P) ==> P"
wenzelm@10276
    92
proof -
wenzelm@10276
    93
  assume tydef: "type_definition Rep Abs A"
wenzelm@10276
    94
  assume r: "!!y. x = Abs y ==> y \<in> A ==> P"
wenzelm@10276
    95
  show P
wenzelm@10276
    96
  proof (rule r)
wenzelm@10276
    97
    have "Abs (Rep x) = x" by (rule Rep_inverse [OF tydef])
wenzelm@10276
    98
    thus "x = Abs (Rep x)" ..
wenzelm@10276
    99
    show "Rep x \<in> A" by (rule Rep [OF tydef])
wenzelm@10276
   100
  qed
wenzelm@10276
   101
qed
wenzelm@10276
   102
wenzelm@10276
   103
theorem Rep_induct:
wenzelm@10276
   104
  "type_definition Rep Abs A ==> y \<in> A ==> (!!x. P (Rep x)) ==> P y"
wenzelm@10276
   105
proof -
wenzelm@10276
   106
  assume tydef: "type_definition Rep Abs A"
wenzelm@10276
   107
  assume "!!x. P (Rep x)" hence "P (Rep (Abs y))" .
wenzelm@10276
   108
  moreover assume "y \<in> A" hence "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
wenzelm@10276
   109
  ultimately show "P y" by (simp only:)
wenzelm@10276
   110
qed
wenzelm@10276
   111
wenzelm@10276
   112
theorem Abs_induct:
wenzelm@10276
   113
  "type_definition Rep Abs A ==> (!!y. y \<in> A ==> P (Abs y)) ==> P x"
wenzelm@10276
   114
proof -
wenzelm@10276
   115
  assume tydef: "type_definition Rep Abs A"
wenzelm@10276
   116
  assume r: "!!y. y \<in> A ==> P (Abs y)"
wenzelm@10276
   117
  have "Rep x \<in> A" by (rule Rep [OF tydef])
wenzelm@10276
   118
  hence "P (Abs (Rep x))" by (rule r)
wenzelm@10276
   119
  moreover have "Abs (Rep x) = x" by (rule Rep_inverse [OF tydef])
wenzelm@10276
   120
  ultimately show "P x" by (simp only:)
wenzelm@10276
   121
qed
wenzelm@10276
   122
wenzelm@10276
   123
setup InductAttrib.setup
wenzelm@10276
   124
use "Tools/typedef_package.ML"
wenzelm@10276
   125
wenzelm@7705
   126
end