src/HOL/Library/Quotient_Type.thy
author wenzelm
Fri, 12 Oct 2012 18:58:20 +0200
changeset 49834 b27bbb021df1
parent 45694 4a8743618257
child 58881 b9556a055632
permissions -rw-r--r--
discontinued obsolete typedef (open) syntax;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35100
53754ec7360b renamed Library/Quotient.thy to Library/Quotient_Type.thy to avoid clash with new theory Quotient in Main HOL;
wenzelm
parents: 30738
diff changeset
     1
(*  Title:      HOL/Library/Quotient_Type.thy
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
     2
    Author:     Markus Wenzel, TU Muenchen
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
     3
*)
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
     4
14706
71590b7733b7 tuned document;
wenzelm
parents: 12371
diff changeset
     5
header {* Quotient types *}
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
     6
35100
53754ec7360b renamed Library/Quotient.thy to Library/Quotient_Type.thy to avoid clash with new theory Quotient in Main HOL;
wenzelm
parents: 30738
diff changeset
     7
theory Quotient_Type
30738
0842e906300c normalized imports
haftmann
parents: 29608
diff changeset
     8
imports Main
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14981
diff changeset
     9
begin
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    10
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    11
text {*
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
    12
 We introduce the notion of quotient types over equivalence relations
22390
378f34b1e380 now using "class"
haftmann
parents: 21404
diff changeset
    13
 via type classes.
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    14
*}
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    15
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
    16
subsection {* Equivalence relations and quotient types *}
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    17
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    18
text {*
10390
wenzelm
parents: 10333
diff changeset
    19
 \medskip Type class @{text equiv} models equivalence relations @{text
wenzelm
parents: 10333
diff changeset
    20
 "\<sim> :: 'a => 'a => bool"}.
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    21
*}
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    22
29608
564ea783ace8 no base sort in class import
haftmann
parents: 27487
diff changeset
    23
class eqv =
25062
af5ef0d4d655 global class syntax
haftmann
parents: 23394
diff changeset
    24
  fixes eqv :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "\<sim>" 50)
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    25
22390
378f34b1e380 now using "class"
haftmann
parents: 21404
diff changeset
    26
class equiv = eqv +
25062
af5ef0d4d655 global class syntax
haftmann
parents: 23394
diff changeset
    27
  assumes equiv_refl [intro]: "x \<sim> x"
af5ef0d4d655 global class syntax
haftmann
parents: 23394
diff changeset
    28
  assumes equiv_trans [trans]: "x \<sim> y \<Longrightarrow> y \<sim> z \<Longrightarrow> x \<sim> z"
af5ef0d4d655 global class syntax
haftmann
parents: 23394
diff changeset
    29
  assumes equiv_sym [sym]: "x \<sim> y \<Longrightarrow> y \<sim> x"
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    30
12371
wenzelm
parents: 12338
diff changeset
    31
lemma equiv_not_sym [sym]: "\<not> (x \<sim> y) ==> \<not> (y \<sim> (x::'a::equiv))"
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    32
proof -
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    33
  assume "\<not> (x \<sim> y)" then show "\<not> (y \<sim> x)"
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    34
    by (rule contrapos_nn) (rule equiv_sym)
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    35
qed
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    36
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    37
lemma not_equiv_trans1 [trans]: "\<not> (x \<sim> y) ==> y \<sim> z ==> \<not> (x \<sim> (z::'a::equiv))"
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    38
proof -
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    39
  assume "\<not> (x \<sim> y)" and "y \<sim> z"
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    40
  show "\<not> (x \<sim> z)"
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    41
  proof
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    42
    assume "x \<sim> z"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    43
    also from `y \<sim> z` have "z \<sim> y" ..
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    44
    finally have "x \<sim> y" .
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    45
    with `\<not> (x \<sim> y)` show False by contradiction
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    46
  qed
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    47
qed
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    48
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    49
lemma not_equiv_trans2 [trans]: "x \<sim> y ==> \<not> (y \<sim> z) ==> \<not> (x \<sim> (z::'a::equiv))"
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    50
proof -
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    51
  assume "\<not> (y \<sim> z)" then have "\<not> (z \<sim> y)" ..
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    52
  also assume "x \<sim> y" then have "y \<sim> x" ..
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    53
  finally have "\<not> (z \<sim> x)" . then show "(\<not> x \<sim> z)" ..
10477
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    54
qed
c21bee84cefe added not_equiv_sym, not_equiv_trans1/2;
wenzelm
parents: 10473
diff changeset
    55
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    56
text {*
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
    57
 \medskip The quotient type @{text "'a quot"} consists of all
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
    58
 \emph{equivalence classes} over elements of the base type @{typ 'a}.
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    59
*}
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    60
45694
4a8743618257 prefer typedef without extra definition and alternative name;
wenzelm
parents: 35100
diff changeset
    61
definition "quot = {{x. a \<sim> x} | a::'a::eqv. True}"
4a8743618257 prefer typedef without extra definition and alternative name;
wenzelm
parents: 35100
diff changeset
    62
49834
b27bbb021df1 discontinued obsolete typedef (open) syntax;
wenzelm
parents: 45694
diff changeset
    63
typedef 'a quot = "quot :: 'a::eqv set set"
45694
4a8743618257 prefer typedef without extra definition and alternative name;
wenzelm
parents: 35100
diff changeset
    64
  unfolding quot_def by blast
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    65
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    66
lemma quotI [intro]: "{x. a \<sim> x} \<in> quot"
18730
843da46f89ac tuned proofs;
wenzelm
parents: 18551
diff changeset
    67
  unfolding quot_def by blast
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    68
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    69
lemma quotE [elim]: "R \<in> quot ==> (!!a. R = {x. a \<sim> x} ==> C) ==> C"
18730
843da46f89ac tuned proofs;
wenzelm
parents: 18551
diff changeset
    70
  unfolding quot_def by blast
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    71
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    72
text {*
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    73
 \medskip Abstracted equivalence classes are the canonical
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    74
 representation of elements of a quotient type.
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    75
*}
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    76
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18730
diff changeset
    77
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19086
diff changeset
    78
  "class" :: "'a::equiv => 'a quot"  ("\<lfloor>_\<rfloor>") where
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18730
diff changeset
    79
  "\<lfloor>a\<rfloor> = Abs_quot {x. a \<sim> x}"
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    80
10311
wenzelm
parents: 10286
diff changeset
    81
theorem quot_exhaust: "\<exists>a. A = \<lfloor>a\<rfloor>"
10278
ea1bf4b6255c improved typedef;
wenzelm
parents: 10250
diff changeset
    82
proof (cases A)
ea1bf4b6255c improved typedef;
wenzelm
parents: 10250
diff changeset
    83
  fix R assume R: "A = Abs_quot R"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    84
  assume "R \<in> quot" then have "\<exists>a. R = {x. a \<sim> x}" by blast
10278
ea1bf4b6255c improved typedef;
wenzelm
parents: 10250
diff changeset
    85
  with R have "\<exists>a. A = Abs_quot {x. a \<sim> x}" by blast
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
    86
  then show ?thesis unfolding class_def .
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    87
qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    88
10311
wenzelm
parents: 10286
diff changeset
    89
lemma quot_cases [cases type: quot]: "(!!a. A = \<lfloor>a\<rfloor> ==> C) ==> C"
18730
843da46f89ac tuned proofs;
wenzelm
parents: 18551
diff changeset
    90
  using quot_exhaust by blast
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    91
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    92
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
    93
subsection {* Equality on quotients *}
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    94
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    95
text {*
10286
wenzelm
parents: 10285
diff changeset
    96
 Equality of canonical quotient elements coincides with the original
wenzelm
parents: 10285
diff changeset
    97
 relation.
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    98
*}
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
    99
12371
wenzelm
parents: 12338
diff changeset
   100
theorem quot_equality [iff?]: "(\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>) = (a \<sim> b)"
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   101
proof
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   102
  assume eq: "\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   103
  show "a \<sim> b"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   104
  proof -
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   105
    from eq have "{x. a \<sim> x} = {x. b \<sim> x}"
10551
ec9fab41b3a0 renamed "equivalence_class" to "class";
wenzelm
parents: 10505
diff changeset
   106
      by (simp only: class_def Abs_quot_inject quotI)
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   107
    moreover have "a \<sim> a" ..
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   108
    ultimately have "a \<in> {x. b \<sim> x}" by blast
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   109
    then have "b \<sim> a" by blast
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   110
    then show ?thesis ..
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   111
  qed
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   112
next
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   113
  assume ab: "a \<sim> b"
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   114
  show "\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   115
  proof -
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   116
    have "{x. a \<sim> x} = {x. b \<sim> x}"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   117
    proof (rule Collect_cong)
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   118
      fix x show "(a \<sim> x) = (b \<sim> x)"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   119
      proof
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   120
        from ab have "b \<sim> a" ..
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   121
        also assume "a \<sim> x"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   122
        finally show "b \<sim> x" .
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   123
      next
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   124
        note ab
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   125
        also assume "b \<sim> x"
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   126
        finally show "a \<sim> x" .
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   127
      qed
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   128
    qed
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   129
    then show ?thesis by (simp only: class_def)
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   130
  qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   131
qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   132
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   133
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   134
subsection {* Picking representing elements *}
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   135
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18730
diff changeset
   136
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19086
diff changeset
   137
  pick :: "'a::equiv quot => 'a" where
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18730
diff changeset
   138
  "pick A = (SOME a. A = \<lfloor>a\<rfloor>)"
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   139
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   140
theorem pick_equiv [intro]: "pick \<lfloor>a\<rfloor> \<sim> a"
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   141
proof (unfold pick_def)
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   142
  show "(SOME x. \<lfloor>a\<rfloor> = \<lfloor>x\<rfloor>) \<sim> a"
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   143
  proof (rule someI2)
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   144
    show "\<lfloor>a\<rfloor> = \<lfloor>a\<rfloor>" ..
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   145
    fix x assume "\<lfloor>a\<rfloor> = \<lfloor>x\<rfloor>"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   146
    then have "a \<sim> x" .. then show "x \<sim> a" ..
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   147
  qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   148
qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   149
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   150
theorem pick_inverse [intro]: "\<lfloor>pick A\<rfloor> = A"
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   151
proof (cases A)
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   152
  fix a assume a: "A = \<lfloor>a\<rfloor>"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   153
  then have "pick A \<sim> a" by (simp only: pick_equiv)
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   154
  then have "\<lfloor>pick A\<rfloor> = \<lfloor>a\<rfloor>" ..
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   155
  with a show ?thesis by simp
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   156
qed
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   157
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   158
text {*
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   159
 \medskip The following rules support canonical function definitions
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   160
 on quotient types (with up to two arguments).  Note that the
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   161
 stripped-down version without additional conditions is sufficient
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   162
 most of the time.
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   163
*}
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   164
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   165
theorem quot_cond_function:
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   166
  assumes eq: "!!X Y. P X Y ==> f X Y == g (pick X) (pick Y)"
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   167
    and cong: "!!x x' y y'. \<lfloor>x\<rfloor> = \<lfloor>x'\<rfloor> ==> \<lfloor>y\<rfloor> = \<lfloor>y'\<rfloor>
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   168
      ==> P \<lfloor>x\<rfloor> \<lfloor>y\<rfloor> ==> P \<lfloor>x'\<rfloor> \<lfloor>y'\<rfloor> ==> g x y = g x' y'"
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   169
    and P: "P \<lfloor>a\<rfloor> \<lfloor>b\<rfloor>"
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   170
  shows "f \<lfloor>a\<rfloor> \<lfloor>b\<rfloor> = g a b"
10473
4f15b844fea6 separate rules for function/operation definitions;
wenzelm
parents: 10459
diff changeset
   171
proof -
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   172
  from eq and P have "f \<lfloor>a\<rfloor> \<lfloor>b\<rfloor> = g (pick \<lfloor>a\<rfloor>) (pick \<lfloor>b\<rfloor>)" by (simp only:)
10505
b89e6cc963e3 unsymbolize;
wenzelm
parents: 10499
diff changeset
   173
  also have "... = g a b"
10491
e4a408728012 quot_cond_function: simplified, support conditional definition;
wenzelm
parents: 10483
diff changeset
   174
  proof (rule cong)
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   175
    show "\<lfloor>pick \<lfloor>a\<rfloor>\<rfloor> = \<lfloor>a\<rfloor>" ..
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   176
    moreover
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   177
    show "\<lfloor>pick \<lfloor>b\<rfloor>\<rfloor> = \<lfloor>b\<rfloor>" ..
10491
e4a408728012 quot_cond_function: simplified, support conditional definition;
wenzelm
parents: 10483
diff changeset
   178
    moreover
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22473
diff changeset
   179
    show "P \<lfloor>a\<rfloor> \<lfloor>b\<rfloor>" by (rule P)
10491
e4a408728012 quot_cond_function: simplified, support conditional definition;
wenzelm
parents: 10483
diff changeset
   180
    ultimately show "P \<lfloor>pick \<lfloor>a\<rfloor>\<rfloor> \<lfloor>pick \<lfloor>b\<rfloor>\<rfloor>" by (simp only:)
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   181
  qed
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   182
  finally show ?thesis .
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   183
qed
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   184
10483
eb93ace45a6e removed quot_cond_function1, quot_function1;
wenzelm
parents: 10477
diff changeset
   185
theorem quot_function:
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   186
  assumes "!!X Y. f X Y == g (pick X) (pick Y)"
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   187
    and "!!x x' y y'. \<lfloor>x\<rfloor> = \<lfloor>x'\<rfloor> ==> \<lfloor>y\<rfloor> = \<lfloor>y'\<rfloor> ==> g x y = g x' y'"
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   188
  shows "f \<lfloor>a\<rfloor> \<lfloor>b\<rfloor> = g a b"
23394
474ff28210c0 tuned proofs;
wenzelm
parents: 23373
diff changeset
   189
  using assms and TrueI
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   190
  by (rule quot_cond_function)
10285
6949e17f314a simplified quotients (only plain total equivs);
wenzelm
parents: 10278
diff changeset
   191
10499
2f33d0fd242e alternative function definition;
bauerg
parents: 10491
diff changeset
   192
theorem quot_function':
2f33d0fd242e alternative function definition;
bauerg
parents: 10491
diff changeset
   193
  "(!!X Y. f X Y == g (pick X) (pick Y)) ==>
2f33d0fd242e alternative function definition;
bauerg
parents: 10491
diff changeset
   194
    (!!x x' y y'. x \<sim> x' ==> y \<sim> y' ==> g x y = g x' y') ==>
2f33d0fd242e alternative function definition;
bauerg
parents: 10491
diff changeset
   195
    f \<lfloor>a\<rfloor> \<lfloor>b\<rfloor> = g a b"
18372
2bffdf62fe7f tuned proofs;
wenzelm
parents: 15140
diff changeset
   196
  by (rule quot_function) (simp_all only: quot_equality)
10499
2f33d0fd242e alternative function definition;
bauerg
parents: 10491
diff changeset
   197
10250
ca93fe25a84b Quotient types;
wenzelm
parents:
diff changeset
   198
end