src/HOL/Equiv_Relations.thy
author paulson <lp15@cam.ac.uk>
Sat, 28 Mar 2020 17:27:01 +0000
changeset 71608 856c68ab6f13
parent 71393 fce780f9c9c6
child 73139 be9b73dfd3e0
permissions -rw-r--r--
structured a lot of ancient, horrible proofs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
     1
(*  Title:      HOL/Equiv_Relations.thy
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
     2
    Author:     Lawrence C Paulson, 1996 Cambridge University Computer Laboratory
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     3
*)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     4
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
     5
section \<open>Equivalence Relations in Higher-Order Set Theory\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     6
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     7
theory Equiv_Relations
66364
fa3247e6ee4b tuning imports
blanchet
parents: 63653
diff changeset
     8
  imports Groups_Big
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     9
begin
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    10
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    11
subsection \<open>Equivalence relations -- set version\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    12
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    13
definition equiv :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    14
  where "equiv A r \<longleftrightarrow> refl_on A r \<and> sym r \<and> trans r"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    15
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    16
lemma equivI: "refl_on A r \<Longrightarrow> sym r \<Longrightarrow> trans r \<Longrightarrow> equiv A r"
40815
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    17
  by (simp add: equiv_def)
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    18
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    19
lemma equivE:
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    20
  assumes "equiv A r"
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    21
  obtains "refl_on A r" and "sym r" and "trans r"
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    22
  using assms by (simp add: equiv_def)
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    23
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    24
text \<open>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    25
  Suppes, Theorem 70: \<open>r\<close> is an equiv relation iff \<open>r\<inverse> O r = r\<close>.
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    26
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    27
  First half: \<open>equiv A r \<Longrightarrow> r\<inverse> O r = r\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    28
\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    29
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    30
lemma sym_trans_comp_subset: "sym r \<Longrightarrow> trans r \<Longrightarrow> r\<inverse> O r \<subseteq> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    31
  unfolding trans_def sym_def converse_unfold by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    32
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    33
lemma refl_on_comp_subset: "refl_on A r \<Longrightarrow> r \<subseteq> r\<inverse> O r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    34
  unfolding refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    35
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    36
lemma equiv_comp_eq: "equiv A r \<Longrightarrow> r\<inverse> O r = r"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    37
  unfolding equiv_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    38
  by (iprover intro: sym_trans_comp_subset refl_on_comp_subset equalityI)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    39
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    40
text \<open>Second half.\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    41
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    42
lemma comp_equivI:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    43
  assumes "r\<inverse> O r = r" "Domain r = A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    44
  shows "equiv A r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    45
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    46
  have *: "\<And>x y. (x, y) \<in> r \<Longrightarrow> (y, x) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    47
    using assms by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    48
  show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    49
    unfolding equiv_def refl_on_def sym_def trans_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    50
    using assms by (auto intro: *)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    51
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    52
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    53
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    54
subsection \<open>Equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    55
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    56
lemma equiv_class_subset: "equiv A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> r``{a} \<subseteq> r``{b}"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
    57
  \<comment> \<open>lemma for the next result\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    58
  unfolding equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    59
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    60
theorem equiv_class_eq: "equiv A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> r``{a} = r``{b}"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    61
  by (intro equalityI equiv_class_subset; force simp add: equiv_def sym_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    62
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    63
lemma equiv_class_self: "equiv A r \<Longrightarrow> a \<in> A \<Longrightarrow> a \<in> r``{a}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    64
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    65
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    66
lemma subset_equiv_class: "equiv A r \<Longrightarrow> r``{b} \<subseteq> r``{a} \<Longrightarrow> b \<in> A \<Longrightarrow> (a, b) \<in> r"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
    67
  \<comment> \<open>lemma for the next result\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    68
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    69
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    70
lemma eq_equiv_class: "r``{a} = r``{b} \<Longrightarrow> equiv A r \<Longrightarrow> b \<in> A \<Longrightarrow> (a, b) \<in> r"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 15539
diff changeset
    71
  by (iprover intro: equalityD2 subset_equiv_class)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    72
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    73
lemma equiv_class_nondisjoint: "equiv A r \<Longrightarrow> x \<in> (r``{a} \<inter> r``{b}) \<Longrightarrow> (a, b) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    74
  unfolding equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    75
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    76
lemma equiv_type: "equiv A r \<Longrightarrow> r \<subseteq> A \<times> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    77
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    78
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    79
lemma equiv_class_eq_iff: "equiv A r \<Longrightarrow> (x, y) \<in> r \<longleftrightarrow> r``{x} = r``{y} \<and> x \<in> A \<and> y \<in> A"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    80
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    81
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    82
lemma eq_equiv_class_iff: "equiv A r \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> r``{x} = r``{y} \<longleftrightarrow> (x, y) \<in> r"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    83
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    84
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    85
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    86
subsection \<open>Quotients\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    87
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    88
definition quotient :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set set"  (infixl "'/'/" 90)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    89
  where "A//r = (\<Union>x \<in> A. {r``{x}})"  \<comment> \<open>set of equiv classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    90
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    91
lemma quotientI: "x \<in> A \<Longrightarrow> r``{x} \<in> A//r"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    92
  unfolding quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    93
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    94
lemma quotientE: "X \<in> A//r \<Longrightarrow> (\<And>x. X = r``{x} \<Longrightarrow> x \<in> A \<Longrightarrow> P) \<Longrightarrow> P"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    95
  unfolding quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    96
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    97
lemma Union_quotient: "equiv A r \<Longrightarrow> \<Union>(A//r) = A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    98
  unfolding equiv_def refl_on_def quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    99
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   100
lemma quotient_disj: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> Y \<in> A//r \<Longrightarrow> X = Y \<or> X \<inter> Y = {}"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   101
  unfolding quotient_def equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   102
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   103
lemma quotient_eqI:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   104
  assumes "equiv A r" "X \<in> A//r" "Y \<in> A//r" and xy: "x \<in> X" "y \<in> Y" "(x, y) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   105
  shows "X = Y"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   106
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   107
  obtain a b where "a \<in> A" and a: "X = r `` {a}" and "b \<in> A" and b: "Y = r `` {b}"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   108
    using assms by (auto elim!: quotientE)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   109
  then have "(a,b) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   110
      using xy \<open>equiv A r\<close> unfolding equiv_def sym_def trans_def by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   111
  then show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   112
    unfolding a b by (rule equiv_class_eq [OF \<open>equiv A r\<close>])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   113
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   114
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   115
lemma quotient_eq_iff:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   116
  assumes "equiv A r" "X \<in> A//r" "Y \<in> A//r" and xy: "x \<in> X" "y \<in> Y" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   117
  shows "X = Y \<longleftrightarrow> (x, y) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   118
proof
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   119
  assume L: "X = Y" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   120
  with assms show "(x, y) \<in> r" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   121
    unfolding equiv_def sym_def trans_def by (blast elim!: quotientE)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   122
next
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   123
  assume \<section>: "(x, y) \<in> r" show "X = Y"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   124
    by (rule quotient_eqI) (use \<section> assms in \<open>blast+\<close>)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   125
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   126
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   127
lemma eq_equiv_class_iff2: "equiv A r \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> {x}//r = {y}//r \<longleftrightarrow> (x, y) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   128
  by (simp add: quotient_def eq_equiv_class_iff)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   129
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   130
lemma quotient_empty [simp]: "{}//r = {}"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   131
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   132
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   133
lemma quotient_is_empty [iff]: "A//r = {} \<longleftrightarrow> A = {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   134
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   135
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   136
lemma quotient_is_empty2 [iff]: "{} = A//r \<longleftrightarrow> A = {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   137
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   138
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   139
lemma singleton_quotient: "{x}//r = {r `` {x}}"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   140
  by (simp add: quotient_def)
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   141
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   142
lemma quotient_diff1: "inj_on (\<lambda>a. {a}//r) A \<Longrightarrow> a \<in> A \<Longrightarrow> (A - {a})//r = A//r - {a}//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   143
  unfolding quotient_def inj_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   144
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   145
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   146
subsection \<open>Refinement of one equivalence relation WRT another\<close>
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   147
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   148
lemma refines_equiv_class_eq: "R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> R``(S``{a}) = S``{a}"
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   149
  by (auto simp: equiv_class_eq_iff)
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   150
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   151
lemma refines_equiv_class_eq2: "R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> S``(R``{a}) = S``{a}"
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   152
  by (auto simp: equiv_class_eq_iff)
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   153
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   154
lemma refines_equiv_image_eq: "R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> (\<lambda>X. S``X) ` (A//R) = A//S"
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   155
   by (auto simp: quotient_def image_UN refines_equiv_class_eq2)
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   156
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   157
lemma finite_refines_finite:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   158
  "finite (A//R) \<Longrightarrow> R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> finite (A//S)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   159
  by (erule finite_surj [where f = "\<lambda>X. S``X"]) (simp add: refines_equiv_image_eq)
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   160
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   161
lemma finite_refines_card_le:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   162
  "finite (A//R) \<Longrightarrow> R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> card (A//S) \<le> card (A//R)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   163
  by (subst refines_equiv_image_eq [of R S A, symmetric])
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   164
    (auto simp: card_image_le [where f = "\<lambda>X. S``X"])
59528
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   165
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   166
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   167
subsection \<open>Defining unary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   168
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   169
text \<open>A congruence-preserving function.\<close>
40816
19c492929756 replaced slightly odd locale congruent by plain definition
haftmann
parents: 40815
diff changeset
   170
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   171
definition congruent :: "('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   172
  where "congruent r f \<longleftrightarrow> (\<forall>(y, z) \<in> r. f y = f z)"
40816
19c492929756 replaced slightly odd locale congruent by plain definition
haftmann
parents: 40815
diff changeset
   173
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   174
lemma congruentI: "(\<And>y z. (y, z) \<in> r \<Longrightarrow> f y = f z) \<Longrightarrow> congruent r f"
40817
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   175
  by (auto simp add: congruent_def)
40816
19c492929756 replaced slightly odd locale congruent by plain definition
haftmann
parents: 40815
diff changeset
   176
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   177
lemma congruentD: "congruent r f \<Longrightarrow> (y, z) \<in> r \<Longrightarrow> f y = f z"
40817
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   178
  by (auto simp add: congruent_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   179
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   180
abbreviation RESPECTS :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"  (infixr "respects" 80)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   181
  where "f respects r \<equiv> congruent r f"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   182
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   183
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   184
lemma UN_constant_eq: "a \<in> A \<Longrightarrow> \<forall>y \<in> A. f y = c \<Longrightarrow> (\<Union>y \<in> A. f y) = c"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   185
  \<comment> \<open>lemma required to prove \<open>UN_equiv_class\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   186
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   187
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   188
lemma UN_equiv_class:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   189
  assumes "equiv A r" "f respects r" "a \<in> A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   190
  shows "(\<Union>x \<in> r``{a}. f x) = f a"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   191
  \<comment> \<open>Conversion rule\<close>
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   192
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   193
  have \<section>: "\<forall>x\<in>r `` {a}. f x = f a"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   194
    using assms unfolding equiv_def congruent_def sym_def by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   195
  show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   196
    by (iprover intro: assms UN_constant_eq [OF equiv_class_self \<section>])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   197
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   198
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   199
lemma UN_equiv_class_type:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   200
  assumes r: "equiv A r" "f respects r" and X: "X \<in> A//r" and AB: "\<And>x. x \<in> A \<Longrightarrow> f x \<in> B"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   201
  shows "(\<Union>x \<in> X. f x) \<in> B"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   202
  using assms unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   203
  by (auto simp: UN_equiv_class [OF r])
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   204
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   205
text \<open>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   206
  Sufficient conditions for injectiveness.  Could weaken premises!
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   207
  major premise could be an inclusion; \<open>bcong\<close> could be
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   208
  \<open>\<And>y. y \<in> A \<Longrightarrow> f y \<in> B\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   209
\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   210
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   211
lemma UN_equiv_class_inject:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   212
  assumes "equiv A r" "f respects r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   213
    and eq: "(\<Union>x \<in> X. f x) = (\<Union>y \<in> Y. f y)" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   214
    and X: "X \<in> A//r" and Y: "Y \<in> A//r" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   215
    and fr: "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> f x = f y \<Longrightarrow> (x, y) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   216
  shows "X = Y"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   217
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   218
  obtain a b where "a \<in> A" and a: "X = r `` {a}" and "b \<in> A" and b: "Y = r `` {b}"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   219
    using assms by (auto elim!: quotientE)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   220
  then have "\<Union> (f ` r `` {a}) = f a" "\<Union> (f ` r `` {b}) = f b"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   221
    by (iprover intro: UN_equiv_class [OF \<open>equiv A r\<close>] assms)+
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   222
  then have "f a = f b"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   223
    using eq unfolding a b by (iprover intro: trans sym)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   224
  then have "(a,b) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   225
    using fr \<open>a \<in> A\<close> \<open>b \<in> A\<close> by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   226
  then show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   227
    unfolding a b by (rule equiv_class_eq [OF \<open>equiv A r\<close>])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   228
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   229
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   230
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   231
subsection \<open>Defining binary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   232
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   233
text \<open>A congruence-preserving function of two arguments.\<close>
40817
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   234
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   235
definition congruent2 :: "('a \<times> 'a) set \<Rightarrow> ('b \<times> 'b) set \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   236
  where "congruent2 r1 r2 f \<longleftrightarrow> (\<forall>(y1, z1) \<in> r1. \<forall>(y2, z2) \<in> r2. f y1 y2 = f z1 z2)"
40817
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   237
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   238
lemma congruent2I':
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   239
  assumes "\<And>y1 z1 y2 z2. (y1, z1) \<in> r1 \<Longrightarrow> (y2, z2) \<in> r2 \<Longrightarrow> f y1 y2 = f z1 z2"
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   240
  shows "congruent2 r1 r2 f"
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   241
  using assms by (auto simp add: congruent2_def)
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   242
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   243
lemma congruent2D: "congruent2 r1 r2 f \<Longrightarrow> (y1, z1) \<in> r1 \<Longrightarrow> (y2, z2) \<in> r2 \<Longrightarrow> f y1 y2 = f z1 z2"
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 61952
diff changeset
   244
  by (auto simp add: congruent2_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   245
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   246
text \<open>Abbreviation for the common case where the relations are identical.\<close>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   247
abbreviation RESPECTS2:: "('a \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"  (infixr "respects2" 80)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   248
  where "f respects2 r \<equiv> congruent2 r r f"
19979
a0846edbe8b0 replaced translation by abbreviation
nipkow
parents: 19363
diff changeset
   249
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   250
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   251
lemma congruent2_implies_congruent:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   252
  "equiv A r1 \<Longrightarrow> congruent2 r1 r2 f \<Longrightarrow> a \<in> A \<Longrightarrow> congruent r2 (f a)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   253
  unfolding congruent_def congruent2_def equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   254
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   255
lemma congruent2_implies_congruent_UN:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   256
  assumes "equiv A1 r1" "equiv A2 r2" "congruent2 r1 r2 f" "a \<in> A2" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   257
  shows "congruent r1 (\<lambda>x1. \<Union>x2 \<in> r2``{a}. f x1 x2)"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   258
  unfolding congruent_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   259
proof clarify
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   260
  fix c d
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   261
  assume cd: "(c,d) \<in> r1"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   262
  then have "c \<in> A1" "d \<in> A1"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   263
    using \<open>equiv A1 r1\<close> by (auto elim!: equiv_type [THEN subsetD, THEN SigmaE2])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   264
  with assms show "\<Union> (f c ` r2 `` {a}) = \<Union> (f d ` r2 `` {a})"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   265
  proof (simp add: UN_equiv_class congruent2_implies_congruent)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   266
    show "f c a = f d a"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   267
      using assms cd unfolding congruent2_def equiv_def refl_on_def by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   268
  qed
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   269
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   270
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   271
lemma UN_equiv_class2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   272
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f \<Longrightarrow> a1 \<in> A1 \<Longrightarrow> a2 \<in> A2 \<Longrightarrow>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   273
    (\<Union>x1 \<in> r1``{a1}. \<Union>x2 \<in> r2``{a2}. f x1 x2) = f a1 a2"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   274
  by (simp add: UN_equiv_class congruent2_implies_congruent congruent2_implies_congruent_UN)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   275
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   276
lemma UN_equiv_class_type2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   277
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   278
    \<Longrightarrow> X1 \<in> A1//r1 \<Longrightarrow> X2 \<in> A2//r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   279
    \<Longrightarrow> (\<And>x1 x2. x1 \<in> A1 \<Longrightarrow> x2 \<in> A2 \<Longrightarrow> f x1 x2 \<in> B)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   280
    \<Longrightarrow> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. f x1 x2) \<in> B"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   281
  unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   282
  by (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   283
                   congruent2_implies_congruent quotientI)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   284
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   285
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   286
lemma UN_UN_split_split_eq:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   287
  "(\<Union>(x1, x2) \<in> X. \<Union>(y1, y2) \<in> Y. A x1 x2 y1 y2) =
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   288
    (\<Union>x \<in> X. \<Union>y \<in> Y. (\<lambda>(x1, x2). (\<lambda>(y1, y2). A x1 x2 y1 y2) y) x)"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   289
  \<comment> \<open>Allows a natural expression of binary operators,\<close>
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   290
  \<comment> \<open>without explicit calls to \<open>split\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   291
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   292
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   293
lemma congruent2I:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   294
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   295
    \<Longrightarrow> (\<And>y z w. w \<in> A2 \<Longrightarrow> (y,z) \<in> r1 \<Longrightarrow> f y w = f z w)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   296
    \<Longrightarrow> (\<And>y z w. w \<in> A1 \<Longrightarrow> (y,z) \<in> r2 \<Longrightarrow> f w y = f w z)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   297
    \<Longrightarrow> congruent2 r1 r2 f"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   298
  \<comment> \<open>Suggested by John Harrison -- the two subproofs may be\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   299
  \<comment> \<open>\<^emph>\<open>much\<close> simpler than the direct proof.\<close>
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   300
  unfolding congruent2_def equiv_def refl_on_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   301
  by (blast intro: trans)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   302
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   303
lemma congruent2_commuteI:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   304
  assumes equivA: "equiv A r"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   305
    and commute: "\<And>y z. y \<in> A \<Longrightarrow> z \<in> A \<Longrightarrow> f y z = f z y"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   306
    and congt: "\<And>y z w. w \<in> A \<Longrightarrow> (y,z) \<in> r \<Longrightarrow> f w y = f w z"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   307
  shows "f respects2 r"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   308
proof (rule congruent2I [OF equivA equivA])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   309
  note eqv = equivA [THEN equiv_type, THEN subsetD, THEN SigmaE2]
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   310
  show "\<And>y z w. \<lbrakk>w \<in> A; (y, z) \<in> r\<rbrakk> \<Longrightarrow> f y w = f z w"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   311
    by (iprover intro: commute [THEN trans] sym congt elim: eqv)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   312
  show "\<And>y z w. \<lbrakk>w \<in> A; (y, z) \<in> r\<rbrakk> \<Longrightarrow> f w y = f w z"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   313
    by (iprover intro: congt elim: eqv)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   314
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   315
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   316
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   317
subsection \<open>Quotients and finiteness\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   318
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   319
text \<open>Suggested by Florian Kammüller\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   320
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   321
lemma finite_quotient:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   322
  assumes "finite A" "r \<subseteq> A \<times> A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   323
  shows "finite (A//r)"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   324
    \<comment> \<open>recall @{thm equiv_type}\<close>
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   325
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   326
  have "A//r \<subseteq> Pow A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   327
    using assms unfolding quotient_def by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   328
  moreover have "finite (Pow A)"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   329
    using assms by simp
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   330
  ultimately show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   331
    by (iprover intro: finite_subset)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   332
qed
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   333
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   334
lemma finite_equiv_class: "finite A \<Longrightarrow> r \<subseteq> A \<times> A \<Longrightarrow> X \<in> A//r \<Longrightarrow> finite X"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   335
  unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   336
  by (erule rev_finite_subset) blast
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   337
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   338
lemma equiv_imp_dvd_card:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   339
  assumes "finite A" "equiv A r" "\<And>X. X \<in> A//r \<Longrightarrow> k dvd card X"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   340
  shows "k dvd card A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   341
proof (rule Union_quotient [THEN subst])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   342
  show "k dvd card (\<Union> (A // r))"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   343
    apply (rule dvd_partition)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   344
    using assms
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   345
    by (auto simp: Union_quotient dest: quotient_disj)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   346
qed (use assms in blast)
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   347
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   348
lemma card_quotient_disjoint:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   349
  assumes "finite A" "inj_on (\<lambda>x. {x} // r) A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   350
  shows "card (A//r) = card A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   351
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   352
  have "\<forall>i\<in>A. \<forall>j\<in>A. i \<noteq> j \<longrightarrow> r `` {j} \<noteq> r `` {i}"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   353
    using assms by (fastforce simp add: quotient_def inj_on_def)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   354
  with assms show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   355
    by (simp add: quotient_def card_UN_disjoint)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   356
qed
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   357
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   358
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   359
subsection \<open>Projection\<close>
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   360
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   361
definition proj :: "('b \<times> 'a) set \<Rightarrow> 'b \<Rightarrow> 'a set"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   362
  where "proj r x = r `` {x}"
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   363
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   364
lemma proj_preserves: "x \<in> A \<Longrightarrow> proj r x \<in> A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   365
  unfolding proj_def by (rule quotientI)
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   366
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   367
lemma proj_in_iff:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   368
  assumes "equiv A r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   369
  shows "proj r x \<in> A//r \<longleftrightarrow> x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   370
    (is "?lhs \<longleftrightarrow> ?rhs")
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   371
proof
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   372
  assume ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   373
  then show ?lhs by (simp add: proj_preserves)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   374
next
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   375
  assume ?lhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   376
  then show ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   377
    unfolding proj_def quotient_def
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   378
  proof clarsimp
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   379
    fix y
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   380
    assume y: "y \<in> A" and "r `` {x} = r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   381
    moreover have "y \<in> r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   382
      using assms y unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   383
    ultimately have "(x, y) \<in> r" by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   384
    then show "x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   385
      using assms unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   386
  qed
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   387
qed
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   388
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   389
lemma proj_iff: "equiv A r \<Longrightarrow> {x, y} \<subseteq> A \<Longrightarrow> proj r x = proj r y \<longleftrightarrow> (x, y) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   390
  by (simp add: proj_def eq_equiv_class_iff)
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   391
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   392
(*
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   393
lemma in_proj: "\<lbrakk>equiv A r; x \<in> A\<rbrakk> \<Longrightarrow> x \<in> proj r x"
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   394
unfolding proj_def equiv_def refl_on_def by blast
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   395
*)
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   396
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   397
lemma proj_image: "proj r ` A = A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   398
  unfolding proj_def[abs_def] quotient_def by blast
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   399
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   400
lemma in_quotient_imp_non_empty: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> X \<noteq> {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   401
  unfolding quotient_def using equiv_class_self by fast
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   402
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   403
lemma in_quotient_imp_in_rel: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> {x, y} \<subseteq> X \<Longrightarrow> (x, y) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   404
  using quotient_eq_iff[THEN iffD1] by fastforce
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   405
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   406
lemma in_quotient_imp_closed: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> x \<in> X \<Longrightarrow> (x, y) \<in> r \<Longrightarrow> y \<in> X"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   407
  unfolding quotient_def equiv_def trans_def by blast
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   408
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   409
lemma in_quotient_imp_subset: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> X \<subseteq> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   410
  using in_quotient_imp_in_rel equiv_type by fastforce
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   411
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   412
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   413
subsection \<open>Equivalence relations -- predicate version\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   414
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   415
text \<open>Partial equivalences.\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   416
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   417
definition part_equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   418
  where "part_equivp R \<longleftrightarrow> (\<exists>x. R x x) \<and> (\<forall>x y. R x y \<longleftrightarrow> R x x \<and> R y y \<and> R x = R y)"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   419
    \<comment> \<open>John-Harrison-style characterization\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   420
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   421
lemma part_equivpI: "\<exists>x. R x x \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> part_equivp R"
45969
562e99c3d316 dropped references to obsolete fact `mem_def`
haftmann
parents: 44890
diff changeset
   422
  by (auto simp add: part_equivp_def) (auto elim: sympE transpE)
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   423
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   424
lemma part_equivpE:
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   425
  assumes "part_equivp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   426
  obtains x where "R x x" and "symp R" and "transp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   427
proof -
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   428
  from assms have 1: "\<exists>x. R x x"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   429
    and 2: "\<And>x y. R x y \<longleftrightarrow> R x x \<and> R y y \<and> R x = R y"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   430
    unfolding part_equivp_def by blast+
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   431
  from 1 obtain x where "R x x" ..
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   432
  moreover have "symp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   433
  proof (rule sympI)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   434
    fix x y
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   435
    assume "R x y"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   436
    with 2 [of x y] show "R y x" by auto
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   437
  qed
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   438
  moreover have "transp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   439
  proof (rule transpI)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   440
    fix x y z
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   441
    assume "R x y" and "R y z"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   442
    with 2 [of x y] 2 [of y z] show "R x z" by auto
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   443
  qed
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   444
  ultimately show thesis by (rule that)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   445
qed
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   446
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   447
lemma part_equivp_refl_symp_transp: "part_equivp R \<longleftrightarrow> (\<exists>x. R x x) \<and> symp R \<and> transp R"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   448
  by (auto intro: part_equivpI elim: part_equivpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   449
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   450
lemma part_equivp_symp: "part_equivp R \<Longrightarrow> R x y \<Longrightarrow> R y x"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   451
  by (erule part_equivpE, erule sympE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   452
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   453
lemma part_equivp_transp: "part_equivp R \<Longrightarrow> R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   454
  by (erule part_equivpE, erule transpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   455
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   456
lemma part_equivp_typedef: "part_equivp R \<Longrightarrow> \<exists>d. d \<in> {c. \<exists>x. R x x \<and> c = Collect (R x)}"
44204
3cdc4176638c Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 40945
diff changeset
   457
  by (auto elim: part_equivpE)
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   458
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   459
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   460
text \<open>Total equivalences.\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   461
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   462
definition equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   463
  where "equivp R \<longleftrightarrow> (\<forall>x y. R x y = (R x = R y))" \<comment> \<open>John-Harrison-style characterization\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   464
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   465
lemma equivpI: "reflp R \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> equivp R"
45969
562e99c3d316 dropped references to obsolete fact `mem_def`
haftmann
parents: 44890
diff changeset
   466
  by (auto elim: reflpE sympE transpE simp add: equivp_def)
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   467
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   468
lemma equivpE:
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   469
  assumes "equivp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   470
  obtains "reflp R" and "symp R" and "transp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   471
  using assms by (auto intro!: that reflpI sympI transpI simp add: equivp_def)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   472
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   473
lemma equivp_implies_part_equivp: "equivp R \<Longrightarrow> part_equivp R"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   474
  by (auto intro: part_equivpI elim: equivpE reflpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   475
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   476
lemma equivp_equiv: "equiv UNIV A \<longleftrightarrow> equivp (\<lambda>x y. (x, y) \<in> A)"
46752
e9e7209eb375 more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
haftmann
parents: 45969
diff changeset
   477
  by (auto intro!: equivI equivpI [to_set] elim!: equivE equivpE [to_set])
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   478
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   479
lemma equivp_reflp_symp_transp: "equivp R \<longleftrightarrow> reflp R \<and> symp R \<and> transp R"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   480
  by (auto intro: equivpI elim: equivpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   481
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66364
diff changeset
   482
lemma identity_equivp: "equivp (=)"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   483
  by (auto intro: equivpI reflpI sympI transpI)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   484
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   485
lemma equivp_reflp: "equivp R \<Longrightarrow> R x x"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   486
  by (erule equivpE, erule reflpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   487
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   488
lemma equivp_symp: "equivp R \<Longrightarrow> R x y \<Longrightarrow> R y x"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   489
  by (erule equivpE, erule sympE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   490
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   491
lemma equivp_transp: "equivp R \<Longrightarrow> R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   492
  by (erule equivpE, erule transpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   493
71393
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   494
lemma equivp_rtranclp: "symp r \<Longrightarrow> equivp r\<^sup>*\<^sup>*"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   495
  by(intro equivpI reflpI sympI transpI)(auto dest: sympD[OF symp_rtranclp])
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   496
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   497
lemmas equivp_rtranclp_symclp [simp] = equivp_rtranclp[OF symp_symclp]
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   498
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   499
lemma equivp_vimage2p: "equivp R \<Longrightarrow> equivp (vimage2p f f R)"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   500
  by(auto simp add: equivp_def vimage2p_def dest: fun_cong)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   501
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   502
lemma equivp_imp_transp: "equivp R \<Longrightarrow> transp R"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   503
  by(simp add: equivp_reflp_symp_transp)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   504
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   505
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   506
subsection \<open>Equivalence closure\<close>
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   507
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   508
definition equivclp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" where
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   509
  "equivclp r = (symclp r)\<^sup>*\<^sup>*"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   510
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   511
lemma transp_equivclp [simp]: "transp (equivclp r)"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   512
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   513
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   514
lemma reflp_equivclp [simp]: "reflp (equivclp r)"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   515
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   516
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   517
lemma symp_equivclp [simp]: "symp (equivclp r)"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   518
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   519
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   520
lemma equivp_evquivclp [simp]: "equivp (equivclp r)"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   521
  by(simp add: equivpI)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   522
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   523
lemma tranclp_equivclp [simp]: "(equivclp r)\<^sup>+\<^sup>+ = equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   524
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   525
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   526
lemma rtranclp_equivclp [simp]: "(equivclp r)\<^sup>*\<^sup>* = equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   527
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   528
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   529
lemma symclp_equivclp [simp]: "symclp (equivclp r) = equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   530
  by(simp add: equivclp_def symp_symclp_eq)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   531
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   532
lemma equivclp_symclp [simp]: "equivclp (symclp r) = equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   533
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   534
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   535
lemma equivclp_conversep [simp]: "equivclp (conversep r) = equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   536
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   537
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   538
lemma equivclp_sym [sym]: "equivclp r x y \<Longrightarrow> equivclp r y x"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   539
  by(rule sympD[OF symp_equivclp])
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   540
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   541
lemma equivclp_OO_equivclp_le_equivclp: "equivclp r OO equivclp r \<le> equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   542
  by(rule transp_relcompp_less_eq transp_equivclp)+
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   543
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   544
lemma rtranlcp_le_equivclp: "r\<^sup>*\<^sup>* \<le> equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   545
  unfolding equivclp_def by(rule rtranclp_mono)(simp add: symclp_pointfree)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   546
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   547
lemma rtranclp_conversep_le_equivclp: "r\<inverse>\<inverse>\<^sup>*\<^sup>* \<le> equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   548
  unfolding equivclp_def by(rule rtranclp_mono)(simp add: symclp_pointfree)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   549
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   550
lemma symclp_rtranclp_le_equivclp: "symclp r\<^sup>*\<^sup>* \<le> equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   551
  unfolding symclp_pointfree
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   552
  by(rule le_supI)(simp_all add: rtranclp_conversep[symmetric] rtranlcp_le_equivclp rtranclp_conversep_le_equivclp)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   553
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   554
lemma r_OO_conversep_into_equivclp:
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   555
  "r\<^sup>*\<^sup>* OO r\<inverse>\<inverse>\<^sup>*\<^sup>* \<le> equivclp r"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   556
  by(blast intro: order_trans[OF _ equivclp_OO_equivclp_le_equivclp] relcompp_mono rtranlcp_le_equivclp rtranclp_conversep_le_equivclp del: predicate2I)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   557
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   558
lemma equivclp_induct [consumes 1, case_names base step, induct pred: equivclp]:
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   559
  assumes a: "equivclp r a b"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   560
    and cases: "P a" "\<And>y z. equivclp r a y \<Longrightarrow> r y z \<or> r z y \<Longrightarrow> P y \<Longrightarrow> P z"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   561
  shows "P b"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   562
  using a unfolding equivclp_def
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   563
  by(induction rule: rtranclp_induct; fold equivclp_def; blast intro: cases elim: symclpE)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   564
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   565
lemma converse_equivclp_induct [consumes 1, case_names base step]:
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   566
  assumes major: "equivclp r a b"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   567
    and cases: "P b" "\<And>y z. r y z \<or> r z y \<Longrightarrow> equivclp r z b \<Longrightarrow> P z \<Longrightarrow> P y"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   568
  shows "P a"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   569
  using major unfolding equivclp_def
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   570
  by(induction rule: converse_rtranclp_induct; fold equivclp_def; blast intro: cases elim: symclpE)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   571
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   572
lemma equivclp_refl [simp]: "equivclp r x x"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   573
  by(rule reflpD[OF reflp_equivclp])
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   574
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   575
lemma r_into_equivclp [intro]: "r x y \<Longrightarrow> equivclp r x y"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   576
  unfolding equivclp_def by(blast intro: symclpI)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   577
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   578
lemma converse_r_into_equivclp [intro]: "r y x \<Longrightarrow> equivclp r x y"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   579
  unfolding equivclp_def by(blast intro: symclpI)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   580
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   581
lemma rtranclp_into_equivclp: "r\<^sup>*\<^sup>* x y \<Longrightarrow> equivclp r x y"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   582
  using rtranlcp_le_equivclp[of r] by blast
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   583
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   584
lemma converse_rtranclp_into_equivclp: "r\<^sup>*\<^sup>* y x \<Longrightarrow> equivclp r x y"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   585
  by(blast intro: equivclp_sym rtranclp_into_equivclp)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   586
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   587
lemma equivclp_into_equivclp: "\<lbrakk> equivclp r a b; r b c \<or> r c b \<rbrakk> \<Longrightarrow> equivclp r a c"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   588
  unfolding equivclp_def by(erule rtranclp.rtrancl_into_rtrancl)(auto intro: symclpI)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   589
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   590
lemma equivclp_trans [trans]: "\<lbrakk> equivclp r a b; equivclp r b c \<rbrakk> \<Longrightarrow> equivclp r a c"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   591
  using equivclp_OO_equivclp_le_equivclp[of r] by blast
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   592
55024
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   593
hide_const (open) proj
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   594
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   595
end