src/HOL/Integ/Equiv.thy
author paulson
Wed, 01 Sep 2004 15:04:01 +0200
changeset 15169 2b5da07a0b89
parent 15140 322485b816ac
permissions -rw-r--r--
new "respects" syntax for quotienting
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
     1
(*  Title:      HOL/Integ/Equiv.thy
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
2215
ebf910e7ec87 Tidied up some proofs, ...
paulson
parents: 1642
diff changeset
     3
    Authors:    Lawrence C Paulson, Cambridge University Computer Laboratory
ebf910e7ec87 Tidied up some proofs, ...
paulson
parents: 1642
diff changeset
     4
    Copyright   1996  University of Cambridge
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     5
*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     6
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
     7
header {* Equivalence relations in Higher-Order Set Theory *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
     8
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15108
diff changeset
     9
theory Equiv
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    10
imports Relation Finite_Set
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15108
diff changeset
    11
begin
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    12
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
    13
subsection {* Equivalence relations *}
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    14
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    15
locale equiv =
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    16
  fixes A and r
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    17
  assumes refl: "refl A r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    18
    and sym: "sym r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    19
    and trans: "trans r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    20
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    21
text {*
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    22
  Suppes, Theorem 70: @{text r} is an equiv relation iff @{text "r\<inverse> O
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    23
  r = r"}.
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    24
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    25
  First half: @{text "equiv A r ==> r\<inverse> O r = r"}.
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    26
*}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    27
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    28
lemma sym_trans_comp_subset:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    29
    "sym r ==> trans r ==> r\<inverse> O r \<subseteq> r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    30
  by (unfold trans_def sym_def converse_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    31
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    32
lemma refl_comp_subset: "refl A r ==> r \<subseteq> r\<inverse> O r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    33
  by (unfold refl_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    34
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    35
lemma equiv_comp_eq: "equiv A r ==> r\<inverse> O r = r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    36
  apply (unfold equiv_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    37
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    38
  apply (rule equalityI)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    39
   apply (rules intro: sym_trans_comp_subset refl_comp_subset)+
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    40
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    41
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
    42
text {* Second half. *}
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    43
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    44
lemma comp_equivI:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    45
    "r\<inverse> O r = r ==> Domain r = A ==> equiv A r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    46
  apply (unfold equiv_def refl_def sym_def trans_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    47
  apply (erule equalityE)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    48
  apply (subgoal_tac "\<forall>x y. (x, y) \<in> r --> (y, x) \<in> r")
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    49
   apply fast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    50
  apply fast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    51
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    52
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    53
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    54
subsection {* Equivalence classes *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    55
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    56
lemma equiv_class_subset:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    57
  "equiv A r ==> (a, b) \<in> r ==> r``{a} \<subseteq> r``{b}"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    58
  -- {* lemma for the next result *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    59
  by (unfold equiv_def trans_def sym_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    60
14496
paulson
parents: 14365
diff changeset
    61
theorem equiv_class_eq: "equiv A r ==> (a, b) \<in> r ==> r``{a} = r``{b}"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    62
  apply (assumption | rule equalityI equiv_class_subset)+
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    63
  apply (unfold equiv_def sym_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    64
  apply blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    65
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    66
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    67
lemma equiv_class_self: "equiv A r ==> a \<in> A ==> a \<in> r``{a}"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    68
  by (unfold equiv_def refl_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    69
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    70
lemma subset_equiv_class:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    71
    "equiv A r ==> r``{b} \<subseteq> r``{a} ==> b \<in> A ==> (a,b) \<in> r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    72
  -- {* lemma for the next result *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    73
  by (unfold equiv_def refl_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    74
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    75
lemma eq_equiv_class:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    76
    "r``{a} = r``{b} ==> equiv A r ==> b \<in> A ==> (a, b) \<in> r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    77
  by (rules intro: equalityD2 subset_equiv_class)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    78
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    79
lemma equiv_class_nondisjoint:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    80
    "equiv A r ==> x \<in> (r``{a} \<inter> r``{b}) ==> (a, b) \<in> r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    81
  by (unfold equiv_def trans_def sym_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    82
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    83
lemma equiv_type: "equiv A r ==> r \<subseteq> A \<times> A"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    84
  by (unfold equiv_def refl_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    85
14496
paulson
parents: 14365
diff changeset
    86
theorem equiv_class_eq_iff:
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    87
  "equiv A r ==> ((x, y) \<in> r) = (r``{x} = r``{y} & x \<in> A & y \<in> A)"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    88
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    89
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
    90
theorem eq_equiv_class_iff:
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    91
  "equiv A r ==> x \<in> A ==> y \<in> A ==> (r``{x} = r``{y}) = ((x, y) \<in> r)"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    92
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    93
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    94
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    95
subsection {* Quotients *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    96
9392
c8e6529cc082 changed / to // for quotienting
paulson
parents: 6812
diff changeset
    97
constdefs
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    98
  quotient :: "['a set, ('a*'a) set] => 'a set set"  (infixl "'/'/" 90)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
    99
  "A//r == \<Union>x \<in> A. {r``{x}}"  -- {* set of equiv classes *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   100
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   101
lemma quotientI: "x \<in> A ==> r``{x} \<in> A//r"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   102
  by (unfold quotient_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   103
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   104
lemma quotientE:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   105
  "X \<in> A//r ==> (!!x. X = r``{x} ==> x \<in> A ==> P) ==> P"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   106
  by (unfold quotient_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   107
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   108
lemma Union_quotient: "equiv A r ==> Union (A//r) = A"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   109
  by (unfold equiv_def refl_def quotient_def) blast
9392
c8e6529cc082 changed / to // for quotienting
paulson
parents: 6812
diff changeset
   110
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   111
lemma quotient_disj:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   112
  "equiv A r ==> X \<in> A//r ==> Y \<in> A//r ==> X = Y | (X \<inter> Y = {})"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   113
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   114
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   115
  apply (rule equiv_class_eq)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   116
   apply assumption
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   117
  apply (unfold equiv_def trans_def sym_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   118
  apply blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   119
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   120
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   121
lemma quotient_eqI:
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   122
  "[|equiv A r; X \<in> A//r; Y \<in> A//r; x \<in> X; y \<in> Y; (x,y) \<in> r|] ==> X = Y" 
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   123
  apply (clarify elim!: quotientE)
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   124
  apply (rule equiv_class_eq, assumption)
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   125
  apply (unfold equiv_def sym_def trans_def, blast)
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   126
  done
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   127
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   128
lemma quotient_eq_iff:
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   129
  "[|equiv A r; X \<in> A//r; Y \<in> A//r; x \<in> X; y \<in> Y|] ==> (X = Y) = ((x,y) \<in> r)" 
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   130
  apply (rule iffI)  
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   131
   prefer 2 apply (blast del: equalityI intro: quotient_eqI) 
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   132
  apply (clarify elim!: quotientE)
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   133
  apply (unfold equiv_def sym_def trans_def, blast)
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   134
  done
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 14259
diff changeset
   135
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   136
15108
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   137
lemma quotient_empty [simp]: "{}//r = {}"
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   138
by(simp add: quotient_def)
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   139
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   140
lemma quotient_is_empty [iff]: "(A//r = {}) = (A = {})"
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   141
by(simp add: quotient_def)
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   142
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   143
lemma quotient_is_empty2 [iff]: "({} = A//r) = (A = {})"
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   144
by(simp add: quotient_def)
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   145
492e5f3a8571 added a few thms
nipkow
parents: 14658
diff changeset
   146
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   147
subsection {* Defining unary operations upon equivalence classes *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   148
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   149
text{*A congruence-preserving function*}
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   150
locale congruent =
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   151
  fixes r and f
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   152
  assumes congruent: "(y,z) \<in> r ==> f y = f z"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   153
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   154
syntax
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   155
  RESPECTS ::"['a => 'b, ('a * 'a) set] => bool"  (infixr "respects" 80)
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   156
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   157
translations
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   158
  "f respects r" == "congruent r f"
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   159
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   160
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   161
lemma UN_constant_eq: "a \<in> A ==> \<forall>y \<in> A. f y = c ==> (\<Union>y \<in> A. f(y))=c"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   162
  -- {* lemma required to prove @{text UN_equiv_class} *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   163
  by auto
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   164
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   165
lemma UN_equiv_class:
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   166
  "equiv A r ==> f respects r ==> a \<in> A
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   167
    ==> (\<Union>x \<in> r``{a}. f x) = f a"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   168
  -- {* Conversion rule *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   169
  apply (rule equiv_class_self [THEN UN_constant_eq], assumption+)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   170
  apply (unfold equiv_def congruent_def sym_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   171
  apply (blast del: equalityI)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   172
  done
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   173
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   174
lemma UN_equiv_class_type:
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   175
  "equiv A r ==> f respects r ==> X \<in> A//r ==>
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   176
    (!!x. x \<in> A ==> f x \<in> B) ==> (\<Union>x \<in> X. f x) \<in> B"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   177
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   178
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   179
  apply (subst UN_equiv_class)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   180
     apply auto
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   181
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   182
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   183
text {*
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   184
  Sufficient conditions for injectiveness.  Could weaken premises!
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   185
  major premise could be an inclusion; bcong could be @{text "!!y. y \<in>
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   186
  A ==> f y \<in> B"}.
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   187
*}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   188
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   189
lemma UN_equiv_class_inject:
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   190
  "equiv A r ==> f respects r ==>
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   191
    (\<Union>x \<in> X. f x) = (\<Union>y \<in> Y. f y) ==> X \<in> A//r ==> Y \<in> A//r
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   192
    ==> (!!x y. x \<in> A ==> y \<in> A ==> f x = f y ==> (x, y) \<in> r)
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   193
    ==> X = Y"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   194
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   195
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   196
  apply (rule equiv_class_eq)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   197
   apply assumption
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   198
  apply (subgoal_tac "f x = f xa")
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   199
   apply blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   200
  apply (erule box_equals)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   201
   apply (assumption | rule UN_equiv_class)+
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   202
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   203
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   204
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   205
subsection {* Defining binary operations upon equivalence classes *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   206
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   207
text{*A congruence-preserving function of two arguments*}
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   208
locale congruent2 =
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   209
  fixes r1 and r2 and f
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   210
  assumes congruent2:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   211
    "(y1,z1) \<in> r1 ==> (y2,z2) \<in> r2 ==> f y1 y2 = f z1 z2"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   212
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   213
text{*Abbreviation for the common case where the relations are identical*}
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   214
syntax
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   215
  RESPECTS2 ::"['a => 'b, ('a * 'a) set] => bool"  (infixr "respects2 " 80)
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   216
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   217
translations
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   218
  "f respects2 r" => "congruent2 r r f"
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   219
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   220
lemma congruent2_implies_congruent:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   221
    "equiv A r1 ==> congruent2 r1 r2 f ==> a \<in> A ==> congruent r2 (f a)"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   222
  by (unfold congruent_def congruent2_def equiv_def refl_def) blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   223
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   224
lemma congruent2_implies_congruent_UN:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   225
  "equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f ==> a \<in> A2 ==>
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   226
    congruent r1 (\<lambda>x1. \<Union>x2 \<in> r2``{a}. f x1 x2)"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   227
  apply (unfold congruent_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   228
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   229
  apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   230
  apply (simp add: UN_equiv_class congruent2_implies_congruent)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   231
  apply (unfold congruent2_def equiv_def refl_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   232
  apply (blast del: equalityI)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   233
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   234
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   235
lemma UN_equiv_class2:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   236
  "equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f ==> a1 \<in> A1 ==> a2 \<in> A2
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   237
    ==> (\<Union>x1 \<in> r1``{a1}. \<Union>x2 \<in> r2``{a2}. f x1 x2) = f a1 a2"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   238
  by (simp add: UN_equiv_class congruent2_implies_congruent
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   239
    congruent2_implies_congruent_UN)
9392
c8e6529cc082 changed / to // for quotienting
paulson
parents: 6812
diff changeset
   240
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   241
lemma UN_equiv_class_type2:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   242
  "equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   243
    ==> X1 \<in> A1//r1 ==> X2 \<in> A2//r2
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   244
    ==> (!!x1 x2. x1 \<in> A1 ==> x2 \<in> A2 ==> f x1 x2 \<in> B)
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   245
    ==> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. f x1 x2) \<in> B"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   246
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   247
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   248
  apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   249
    congruent2_implies_congruent quotientI)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   250
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   251
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   252
lemma UN_UN_split_split_eq:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   253
  "(\<Union>(x1, x2) \<in> X. \<Union>(y1, y2) \<in> Y. A x1 x2 y1 y2) =
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   254
    (\<Union>x \<in> X. \<Union>y \<in> Y. (\<lambda>(x1, x2). (\<lambda>(y1, y2). A x1 x2 y1 y2) y) x)"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   255
  -- {* Allows a natural expression of binary operators, *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   256
  -- {* without explicit calls to @{text split} *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   257
  by auto
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   258
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   259
lemma congruent2I:
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   260
  "equiv A1 r1 ==> equiv A2 r2
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   261
    ==> (!!y z w. w \<in> A2 ==> (y,z) \<in> r1 ==> f y w = f z w)
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   262
    ==> (!!y z w. w \<in> A1 ==> (y,z) \<in> r2 ==> f w y = f w z)
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   263
    ==> congruent2 r1 r2 f"
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   264
  -- {* Suggested by John Harrison -- the two subproofs may be *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   265
  -- {* \emph{much} simpler than the direct proof. *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   266
  apply (unfold congruent2_def equiv_def refl_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   267
  apply clarify
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   268
  apply (blast intro: trans)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   269
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   270
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   271
lemma congruent2_commuteI:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   272
  assumes equivA: "equiv A r"
14512
e516d7cfa249 variable renamings and other cosmetic changes
paulson
parents: 14496
diff changeset
   273
    and commute: "!!y z. y \<in> A ==> z \<in> A ==> f y z = f z y"
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   274
    and congt: "!!y z w. w \<in> A ==> (y,z) \<in> r ==> f w y = f w z"
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   275
  shows "f respects2 r"
14658
b1293d0f8d5f congruent2 now allows different equiv relations
paulson
parents: 14512
diff changeset
   276
  apply (rule congruent2I [OF equivA equivA])
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   277
   apply (rule commute [THEN trans])
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   278
     apply (rule_tac [3] commute [THEN trans, symmetric])
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   279
       apply (rule_tac [5] sym)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   280
       apply (assumption | rule congt |
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   281
         erule equivA [THEN equiv_type, THEN subsetD, THEN SigmaE2])+
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   282
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   283
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   284
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   285
subsection {* Cardinality results *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   286
15169
2b5da07a0b89 new "respects" syntax for quotienting
paulson
parents: 15140
diff changeset
   287
text {*Suggested by Florian Kammüller*}
13482
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   288
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   289
lemma finite_quotient: "finite A ==> r \<subseteq> A \<times> A ==> finite (A//r)"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   290
  -- {* recall @{thm equiv_type} *}
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   291
  apply (rule finite_subset)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   292
   apply (erule_tac [2] finite_Pow_iff [THEN iffD2])
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   293
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   294
  apply blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   295
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   296
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   297
lemma finite_equiv_class:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   298
  "finite A ==> r \<subseteq> A \<times> A ==> X \<in> A//r ==> finite X"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   299
  apply (unfold quotient_def)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   300
  apply (rule finite_subset)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   301
   prefer 2 apply assumption
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   302
  apply blast
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   303
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   304
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   305
lemma equiv_imp_dvd_card:
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   306
  "finite A ==> equiv A r ==> \<forall>X \<in> A//r. k dvd card X
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   307
    ==> k dvd card A"
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   308
  apply (rule Union_quotient [THEN subst])
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   309
   apply assumption
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   310
  apply (rule dvd_partition)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   311
     prefer 4 apply (blast dest: quotient_disj)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   312
    apply (simp_all add: Union_quotient equiv_type finite_quotient)
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   313
  done
2bb7200a99cf converted;
wenzelm
parents: 12398
diff changeset
   314
14259
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   315
ML
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   316
{*
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   317
val UN_UN_split_split_eq = thm "UN_UN_split_split_eq";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   318
val UN_constant_eq = thm "UN_constant_eq";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   319
val UN_equiv_class = thm "UN_equiv_class";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   320
val UN_equiv_class2 = thm "UN_equiv_class2";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   321
val UN_equiv_class_inject = thm "UN_equiv_class_inject";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   322
val UN_equiv_class_type = thm "UN_equiv_class_type";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   323
val UN_equiv_class_type2 = thm "UN_equiv_class_type2";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   324
val Union_quotient = thm "Union_quotient";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   325
val comp_equivI = thm "comp_equivI";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   326
val congruent2I = thm "congruent2I";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   327
val congruent2_commuteI = thm "congruent2_commuteI";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   328
val congruent2_def = thm "congruent2_def";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   329
val congruent2_implies_congruent = thm "congruent2_implies_congruent";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   330
val congruent2_implies_congruent_UN = thm "congruent2_implies_congruent_UN";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   331
val congruent_def = thm "congruent_def";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   332
val eq_equiv_class = thm "eq_equiv_class";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   333
val eq_equiv_class_iff = thm "eq_equiv_class_iff";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   334
val equiv_class_eq = thm "equiv_class_eq";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   335
val equiv_class_eq_iff = thm "equiv_class_eq_iff";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   336
val equiv_class_nondisjoint = thm "equiv_class_nondisjoint";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   337
val equiv_class_self = thm "equiv_class_self";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   338
val equiv_comp_eq = thm "equiv_comp_eq";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   339
val equiv_def = thm "equiv_def";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   340
val equiv_imp_dvd_card = thm "equiv_imp_dvd_card";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   341
val equiv_type = thm "equiv_type";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   342
val finite_equiv_class = thm "finite_equiv_class";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   343
val finite_quotient = thm "finite_quotient";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   344
val quotientE = thm "quotientE";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   345
val quotientI = thm "quotientI";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   346
val quotient_def = thm "quotient_def";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   347
val quotient_disj = thm "quotient_disj";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   348
val refl_comp_subset = thm "refl_comp_subset";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   349
val subset_equiv_class = thm "subset_equiv_class";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   350
val sym_trans_comp_subset = thm "sym_trans_comp_subset";
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   351
*}
79f7d3451b1e conversion of ML to Isar scripts
paulson
parents: 13482
diff changeset
   352
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   353
end