src/HOL/Equiv_Relations.thy
author desharna
Fri, 16 Dec 2022 10:34:58 +0100
changeset 76675 0d7a9e4e1d61
parent 75669 43f5dfb7fa35
child 80932 261cd8722677
permissions -rw-r--r--
strengthened and renamed symp_symclp
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
74979
4d77dd3019d1 earlier availability of lifting
haftmann
parents: 74885
diff changeset
     8
  imports BNF_Least_Fixpoint
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
74590
00ffae972fc0 Added / moved some simple set-theoretic lemmas
paulson <lp15@cam.ac.uk>
parents: 73139
diff changeset
    85
lemma disjnt_equiv_class: "equiv A r \<Longrightarrow> disjnt (r``{a}) (r``{b}) \<longleftrightarrow> (a, b) \<notin> r"
00ffae972fc0 Added / moved some simple set-theoretic lemmas
paulson <lp15@cam.ac.uk>
parents: 73139
diff changeset
    86
  by (auto dest: equiv_class_self simp: equiv_class_eq_iff disjnt_def)
00ffae972fc0 Added / moved some simple set-theoretic lemmas
paulson <lp15@cam.ac.uk>
parents: 73139
diff changeset
    87
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    88
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    89
subsection \<open>Quotients\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    90
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    91
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
    92
  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
    93
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
    94
lemma quotientI: "x \<in> A \<Longrightarrow> r``{x} \<in> A//r"
63653
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 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
    98
  unfolding 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 Union_quotient: "equiv A r \<Longrightarrow> \<Union>(A//r) = A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   101
  unfolding equiv_def refl_on_def quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   102
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   103
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
   104
  unfolding quotient_def equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   105
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   106
lemma quotient_eqI:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   107
  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
   108
  shows "X = Y"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   109
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   110
  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
   111
    using assms by (auto elim!: quotientE)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   112
  then have "(a,b) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   113
      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
   114
  then show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   115
    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
   116
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   117
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   118
lemma quotient_eq_iff:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   119
  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
   120
  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
   121
proof
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   122
  assume L: "X = Y" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   123
  with assms show "(x, y) \<in> r" 
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   124
    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
   125
next
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   126
  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
   127
    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
   128
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   129
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   130
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
   131
  by (simp add: quotient_def eq_equiv_class_iff)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   132
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   133
lemma quotient_empty [simp]: "{}//r = {}"
63653
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_empty [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
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   139
lemma quotient_is_empty2 [iff]: "{} = A//r \<longleftrightarrow> A = {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   140
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   141
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   142
lemma singleton_quotient: "{x}//r = {r `` {x}}"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   143
  by (simp add: quotient_def)
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   144
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   145
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
   146
  unfolding quotient_def inj_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   147
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   148
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   149
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
   150
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   151
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
   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_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
   155
  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
   156
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   157
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
   158
   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
   159
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   160
lemma finite_refines_finite:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   161
  "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
   162
  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
   163
4862f3dc9540 new lemmas re refinement of one equivalence relation WRT another
paulson <lp15@cam.ac.uk>
parents: 58889
diff changeset
   164
lemma finite_refines_card_le:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   165
  "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
   166
  by (subst refines_equiv_image_eq [of R S A, symmetric])
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   167
    (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
   168
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   169
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   170
subsection \<open>Defining unary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   171
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   172
text \<open>A congruence-preserving function.\<close>
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
definition congruent :: "('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   175
  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
   176
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   177
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
   178
  by (auto simp add: congruent_def)
40816
19c492929756 replaced slightly odd locale congruent by plain definition
haftmann
parents: 40815
diff changeset
   179
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   180
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
   181
  by (auto simp add: congruent_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   182
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   183
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
   184
  where "f respects r \<equiv> congruent r f"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   185
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   186
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   187
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
   188
  \<comment> \<open>lemma required to prove \<open>UN_equiv_class\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   189
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   190
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   191
lemma UN_equiv_class:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   192
  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
   193
  shows "(\<Union>x \<in> r``{a}. f x) = f a"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   194
  \<comment> \<open>Conversion rule\<close>
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   195
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   196
  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
   197
    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
   198
  show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   199
    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
   200
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   201
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   202
lemma UN_equiv_class_type:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   203
  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
   204
  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
   205
  using assms unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   206
  by (auto simp: UN_equiv_class [OF r])
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   207
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   208
text \<open>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   209
  Sufficient conditions for injectiveness.  Could weaken premises!
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   210
  major premise could be an inclusion; \<open>bcong\<close> could be
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   211
  \<open>\<And>y. y \<in> A \<Longrightarrow> f y \<in> B\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   212
\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   213
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   214
lemma UN_equiv_class_inject:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   215
  assumes "equiv A r" "f respects r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   216
    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
   217
    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
   218
    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
   219
  shows "X = Y"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   220
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   221
  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
   222
    using assms by (auto elim!: quotientE)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   223
  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
   224
    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
   225
  then have "f a = f b"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   226
    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
   227
  then have "(a,b) \<in> r"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   228
    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
   229
  then show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   230
    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
   231
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   232
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   233
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   234
subsection \<open>Defining binary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   235
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   236
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
   237
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   238
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
   239
  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
   240
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   241
lemma congruent2I':
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   242
  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
   243
  shows "congruent2 r1 r2 f"
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   244
  using assms by (auto simp add: congruent2_def)
781da1e8808c replaced slightly odd locale congruent2 by plain definition
haftmann
parents: 40816
diff changeset
   245
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   246
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
   247
  by (auto simp add: congruent2_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   248
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   249
text \<open>Abbreviation for the common case where the relations are identical.\<close>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   250
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
   251
  where "f respects2 r \<equiv> congruent2 r r f"
19979
a0846edbe8b0 replaced translation by abbreviation
nipkow
parents: 19363
diff changeset
   252
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   253
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   254
lemma congruent2_implies_congruent:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   255
  "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
   256
  unfolding congruent_def congruent2_def equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   257
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   258
lemma congruent2_implies_congruent_UN:
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   259
  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
   260
  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
   261
  unfolding congruent_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   262
proof clarify
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   263
  fix c d
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   264
  assume cd: "(c,d) \<in> r1"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   265
  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
   266
    using \<open>equiv A1 r1\<close> by (auto elim!: equiv_type [THEN subsetD, THEN SigmaE2])
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 74979
diff changeset
   267
  moreover have "f c a = f d a"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 74979
diff changeset
   268
    using assms cd unfolding congruent2_def equiv_def refl_on_def by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 74979
diff changeset
   269
  ultimately show "\<Union> (f c ` r2 `` {a}) = \<Union> (f d ` r2 `` {a})"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 74979
diff changeset
   270
    using assms by (simp add: UN_equiv_class congruent2_implies_congruent)
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   271
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   272
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   273
lemma UN_equiv_class2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   274
  "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
   275
    (\<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
   276
  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
   277
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   278
lemma UN_equiv_class_type2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   279
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   280
    \<Longrightarrow> X1 \<in> A1//r1 \<Longrightarrow> X2 \<in> A2//r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   281
    \<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
   282
    \<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
   283
  unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   284
  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
   285
                   congruent2_implies_congruent quotientI)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   286
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   287
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   288
lemma UN_UN_split_split_eq:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   289
  "(\<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
   290
    (\<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
   291
  \<comment> \<open>Allows a natural expression of binary operators,\<close>
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   292
  \<comment> \<open>without explicit calls to \<open>split\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   293
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   294
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   295
lemma congruent2I:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   296
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   297
    \<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
   298
    \<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
   299
    \<Longrightarrow> congruent2 r1 r2 f"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   300
  \<comment> \<open>Suggested by John Harrison -- the two subproofs may be\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   301
  \<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
   302
  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
   303
  by (blast intro: trans)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   304
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   305
lemma congruent2_commuteI:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   306
  assumes equivA: "equiv A r"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   307
    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
   308
    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
   309
  shows "f respects2 r"
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   310
proof (rule congruent2I [OF equivA equivA])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   311
  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
   312
  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
   313
    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
   314
  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
   315
    by (iprover intro: congt elim: eqv)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   316
qed
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   317
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   318
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   319
subsection \<open>Quotients and finiteness\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   320
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   321
text \<open>Suggested by Florian Kammüller\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   322
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   323
lemma finite_quotient:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   324
  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
   325
  shows "finite (A//r)"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   326
    \<comment> \<open>recall @{thm equiv_type}\<close>
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   327
proof -
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   328
  have "A//r \<subseteq> Pow A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   329
    using assms unfolding quotient_def by blast
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   330
  moreover have "finite (Pow A)"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   331
    using assms by simp
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   332
  ultimately show ?thesis
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   333
    by (iprover intro: finite_subset)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   334
qed
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   335
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   336
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
   337
  unfolding quotient_def
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   338
  by (erule rev_finite_subset) blast
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   339
71608
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   340
lemma equiv_imp_dvd_card:
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   341
  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
   342
  shows "k dvd card A"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   343
proof (rule Union_quotient [THEN subst])
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   344
  show "k dvd card (\<Union> (A // r))"
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   345
    apply (rule dvd_partition)
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   346
    using assms
856c68ab6f13 structured a lot of ancient, horrible proofs
paulson <lp15@cam.ac.uk>
parents: 71393
diff changeset
   347
    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
   348
qed (use assms in blast)
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   349
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   350
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   351
subsection \<open>Projection\<close>
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   352
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   353
definition proj :: "('b \<times> 'a) set \<Rightarrow> 'b \<Rightarrow> 'a set"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   354
  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
   355
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   356
lemma proj_preserves: "x \<in> A \<Longrightarrow> proj r x \<in> A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   357
  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
   358
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   359
lemma proj_in_iff:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   360
  assumes "equiv A r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   361
  shows "proj r x \<in> A//r \<longleftrightarrow> x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   362
    (is "?lhs \<longleftrightarrow> ?rhs")
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   363
proof
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   364
  assume ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   365
  then show ?lhs by (simp add: proj_preserves)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   366
next
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   367
  assume ?lhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   368
  then show ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   369
    unfolding proj_def quotient_def
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 74979
diff changeset
   370
  proof safe
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   371
    fix y
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   372
    assume y: "y \<in> A" and "r `` {x} = r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   373
    moreover have "y \<in> r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   374
      using assms y unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   375
    ultimately have "(x, y) \<in> r" by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   376
    then show "x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   377
      using assms unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   378
  qed
55022
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   379
qed
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   380
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   381
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
   382
  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
   383
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   384
(*
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   385
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
   386
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
   387
*)
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_image: "proj r ` A = A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   390
  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
   391
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   392
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
   393
  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
   394
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   395
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
   396
  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
   397
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   398
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
   399
  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
   400
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   401
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
   402
  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
   403
eeba3ba73486 liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
blanchet
parents: 54744
diff changeset
   404
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   405
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
   406
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   407
text \<open>Partial equivalences.\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   408
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   409
definition part_equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   410
  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
   411
    \<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
   412
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   413
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
   414
  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
   415
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   416
lemma part_equivpE:
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   417
  assumes "part_equivp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   418
  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
   419
proof -
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   420
  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
   421
    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
   422
    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
   423
  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
   424
  moreover have "symp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   425
  proof (rule sympI)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   426
    fix x y
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   427
    assume "R x y"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   428
    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
   429
  qed
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   430
  moreover have "transp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   431
  proof (rule transpI)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   432
    fix x y z
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   433
    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
   434
    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
   435
  qed
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   436
  ultimately show thesis by (rule that)
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
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   439
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
   440
  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
   441
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   442
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
   443
  by (erule part_equivpE, erule sympE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   444
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   445
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
   446
  by (erule part_equivpE, erule transpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   447
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   448
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
   449
  by (auto elim: part_equivpE)
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   450
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   451
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   452
text \<open>Total equivalences.\<close>
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   453
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   454
definition equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   455
  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
   456
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   457
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
   458
  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
   459
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   460
lemma equivpE:
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   461
  assumes "equivp R"
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   462
  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
   463
  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
   464
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   465
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
   466
  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
   467
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   468
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
   469
  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
   470
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   471
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
   472
  by (auto intro: equivpI elim: equivpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   473
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66364
diff changeset
   474
lemma identity_equivp: "equivp (=)"
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   475
  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
   476
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   477
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
   478
  by (erule equivpE, erule reflpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   479
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   480
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
   481
  by (erule equivpE, erule sympE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   482
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   483
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
   484
  by (erule equivpE, erule transpE)
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   485
71393
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   486
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
   487
  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
   488
76675
0d7a9e4e1d61 strengthened and renamed symp_symclp
desharna
parents: 75669
diff changeset
   489
lemmas equivp_rtranclp_symclp [simp] = equivp_rtranclp[OF symp_on_symclp]
71393
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   490
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   491
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
   492
  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
   493
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   494
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
   495
  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
   496
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   497
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   498
subsection \<open>Equivalence closure\<close>
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   499
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   500
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
   501
  "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
   502
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   503
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
   504
  by(simp add: equivclp_def)
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
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
   507
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   508
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   509
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
   510
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   511
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   512
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
   513
  by(simp add: equivpI)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   514
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   515
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
   516
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   517
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   518
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
   519
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   520
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   521
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
   522
  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
   523
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   524
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
   525
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   526
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   527
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
   528
  by(simp add: equivclp_def)
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   529
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   530
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
   531
  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
   532
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   533
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
   534
  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
   535
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   536
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
   537
  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
   538
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   539
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
   540
  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
   541
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   542
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
   543
  unfolding symclp_pointfree
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   544
  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
   545
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   546
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
   547
  "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
   548
  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
   549
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   550
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
   551
  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
   552
    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
   553
  shows "P b"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   554
  using a unfolding equivclp_def
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   555
  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
   556
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   557
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
   558
  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
   559
    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
   560
  shows "P a"
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   561
  using major unfolding equivclp_def
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   562
  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
   563
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   564
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
   565
  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
   566
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   567
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
   568
  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
   569
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   570
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
   571
  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
   572
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   573
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
   574
  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
   575
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   576
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
   577
  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
   578
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   579
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
   580
  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
   581
fce780f9c9c6 new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents: 67399
diff changeset
   582
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
   583
  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
   584
55024
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   585
hide_const (open) proj
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   586
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   587
end