src/HOL/subset.thy
author wenzelm
Fri, 20 Oct 2000 19:46:53 +0200
changeset 10284 ec98fc455272
parent 10276 75e2c6cb4153
child 10290 8018d1743beb
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 923
diff changeset
     1
(*  Title:      HOL/subset.thy
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1475
7f5a4cd08209 expanded tabs; renamed subtype to typedef;
clasohm
parents: 923
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
10276
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
     5
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
     6
Subset lemmas and HOL type definitions.
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
7705
222b715b5d24 Tools/typedef_package.ML;
wenzelm
parents: 5853
diff changeset
     9
theory subset = Set
10276
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    10
files "Tools/induct_attrib.ML" ("Tools/typedef_package.ML"):
7705
222b715b5d24 Tools/typedef_package.ML;
wenzelm
parents: 5853
diff changeset
    11
9895
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    12
(*belongs to theory Ord*)
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    13
theorems linorder_cases [case_names less equal greater] =
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    14
  linorder_less_split
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    15
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    16
(*belongs to theory Set*)
75e55370b1ae added linorder_cases;
wenzelm
parents: 7717
diff changeset
    17
setup Rulify.setup
7717
e7ecfa617443 Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents: 7705
diff changeset
    18
10276
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    19
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    20
section {* HOL type definitions *}
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    21
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    22
constdefs
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    23
  type_definition :: "('a => 'b) => ('b => 'a) => 'b set => bool"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    24
  "type_definition Rep Abs A ==
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    25
    (\<forall>x. Rep x \<in> A) \<and>
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    26
    (\<forall>x. Abs (Rep x) = x) \<and>
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    27
    (\<forall>y \<in> A. Rep (Abs y) = y)"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    28
  -- {* This will be stated as an axiom for each typedef! *}
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    29
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    30
theorem Rep: "type_definition Rep Abs A ==> Rep x \<in> A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    31
  by (unfold type_definition_def) blast
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    32
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    33
theorem Rep_inverse: "type_definition Rep Abs A ==> Abs (Rep x) = x"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    34
  by (unfold type_definition_def) blast
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    35
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    36
theorem Abs_inverse: "type_definition Rep Abs A ==> y \<in> A ==> Rep (Abs y) = y"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    37
  by (unfold type_definition_def) blast
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    38
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    39
theorem Rep_inject: "type_definition Rep Abs A ==> (Rep x = Rep y) = (x = y)"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    40
proof -
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    41
  assume tydef: "type_definition Rep Abs A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    42
  show ?thesis
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    43
  proof
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    44
    assume "Rep x = Rep y"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    45
    hence "Abs (Rep x) = Abs (Rep y)" by (simp only:)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    46
    thus "x = y" by (simp only: Rep_inverse [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    47
  next
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    48
    assume "x = y"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    49
    thus "Rep x = Rep y" by simp
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    50
  qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    51
qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    52
10284
wenzelm
parents: 10276
diff changeset
    53
theorem Abs_inject:
wenzelm
parents: 10276
diff changeset
    54
  "type_definition Rep Abs A ==> x \<in> A ==> y \<in> A ==> (Abs x = Abs y) = (x = y)"
wenzelm
parents: 10276
diff changeset
    55
proof -
wenzelm
parents: 10276
diff changeset
    56
  assume tydef: "type_definition Rep Abs A"
wenzelm
parents: 10276
diff changeset
    57
  assume x: "x \<in> A" and y: "y \<in> A"
wenzelm
parents: 10276
diff changeset
    58
  show ?thesis
wenzelm
parents: 10276
diff changeset
    59
  proof
wenzelm
parents: 10276
diff changeset
    60
    assume "Abs x = Abs y"
wenzelm
parents: 10276
diff changeset
    61
    hence "Rep (Abs x) = Rep (Abs y)" by simp
wenzelm
parents: 10276
diff changeset
    62
    moreover note x hence "Rep (Abs x) = x" by (rule Abs_inverse [OF tydef])
wenzelm
parents: 10276
diff changeset
    63
    moreover note y hence "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
wenzelm
parents: 10276
diff changeset
    64
    ultimately show "x = y" by (simp only:)
wenzelm
parents: 10276
diff changeset
    65
  next
wenzelm
parents: 10276
diff changeset
    66
    assume "x = y"
wenzelm
parents: 10276
diff changeset
    67
    thus "Abs x = Abs y" by simp
wenzelm
parents: 10276
diff changeset
    68
  qed
wenzelm
parents: 10276
diff changeset
    69
qed
wenzelm
parents: 10276
diff changeset
    70
10276
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    71
theorem Rep_cases:
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    72
  "type_definition Rep Abs A ==> y \<in> A ==> (!!x. y = Rep x ==> P) ==> P"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    73
proof -
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    74
  assume tydef: "type_definition Rep Abs A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    75
  assume y: "y \<in> A" and r: "(!!x. y = Rep x ==> P)"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    76
  show P
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    77
  proof (rule r)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    78
    from y have "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    79
    thus "y = Rep (Abs y)" ..
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    80
  qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    81
qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    82
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    83
theorem Abs_cases:
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    84
  "type_definition Rep Abs A ==> (!!y. x = Abs y ==> y \<in> A ==> P) ==> P"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    85
proof -
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    86
  assume tydef: "type_definition Rep Abs A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    87
  assume r: "!!y. x = Abs y ==> y \<in> A ==> P"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    88
  show P
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    89
  proof (rule r)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    90
    have "Abs (Rep x) = x" by (rule Rep_inverse [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    91
    thus "x = Abs (Rep x)" ..
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    92
    show "Rep x \<in> A" by (rule Rep [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    93
  qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    94
qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    95
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    96
theorem Rep_induct:
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    97
  "type_definition Rep Abs A ==> y \<in> A ==> (!!x. P (Rep x)) ==> P y"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    98
proof -
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
    99
  assume tydef: "type_definition Rep Abs A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   100
  assume "!!x. P (Rep x)" hence "P (Rep (Abs y))" .
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   101
  moreover assume "y \<in> A" hence "Rep (Abs y) = y" by (rule Abs_inverse [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   102
  ultimately show "P y" by (simp only:)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   103
qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   104
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   105
theorem Abs_induct:
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   106
  "type_definition Rep Abs A ==> (!!y. y \<in> A ==> P (Abs y)) ==> P x"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   107
proof -
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   108
  assume tydef: "type_definition Rep Abs A"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   109
  assume r: "!!y. y \<in> A ==> P (Abs y)"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   110
  have "Rep x \<in> A" by (rule Rep [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   111
  hence "P (Abs (Rep x))" by (rule r)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   112
  moreover have "Abs (Rep x) = x" by (rule Rep_inverse [OF tydef])
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   113
  ultimately show "P x" by (simp only:)
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   114
qed
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   115
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   116
setup InductAttrib.setup
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   117
use "Tools/typedef_package.ML"
75e2c6cb4153 added theory for HOL type definitions;
wenzelm
parents: 9895
diff changeset
   118
7705
222b715b5d24 Tools/typedef_package.ML;
wenzelm
parents: 5853
diff changeset
   119
end