src/HOL/Integ/Equiv.ML
author clasohm
Fri, 24 Mar 1995 12:30:35 +0100
changeset 972 e61b058d58d2
parent 925 15539deb6863
child 1045 0cdf86973c49
permissions -rw-r--r--
changed syntax of tuples from <..., ...> to (..., ...)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	Equiv.ML
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     3
    Authors: 	Riccardo Mattolini, Dip. Sistemi e Informatica
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     4
        	Lawrence C Paulson, Cambridge University Computer Laboratory
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     5
    Copyright   1994 Universita' di Firenze
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     6
    Copyright   1993  University of Cambridge
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     7
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     8
Equivalence relations in HOL Set Theory 
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
     9
*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    10
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    11
open Equiv;
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    12
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    13
(*** Suppes, Theorem 70: r is an equiv relation iff converse(r) O r = r ***)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    14
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    15
(** first half: equiv A r ==> converse(r) O r = r **)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    16
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    17
goalw Equiv.thy [trans_def,sym_def,converse_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    18
    "!!r. [| sym(r); trans(r) |] ==> converse(r) O r <= r";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    19
by (fast_tac (comp_cs addSEs [converseD]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    20
qed "sym_trans_comp_subset";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    21
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    22
val [major,minor]=goal Equiv.thy "[|(x,y):r; z=(x,y)|] ==>  z:r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    23
by (simp_tac (prod_ss addsimps [minor]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    24
by (rtac major 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    25
qed "BreakPair";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    26
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    27
val [major]=goal Equiv.thy "[|? x y. (x,y):r & z=(x,y)|] ==>  z:r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    28
by (resolve_tac [major RS exE] 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    29
by (etac exE 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    30
by (etac conjE 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    31
by (asm_simp_tac (prod_ss addsimps [minor]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    32
qed "BreakPair1";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    33
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    34
val [major,minor]=goal Equiv.thy "[|z:r; z=(x,y)|] ==> (x,y):r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    35
by (simp_tac (prod_ss addsimps [minor RS sym]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    36
by (rtac major 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    37
qed "BuildPair";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    38
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    39
val [major]=goal Equiv.thy "[|? z:r. (x,y)=z|] ==> (x,y):r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    40
by (resolve_tac [major RS bexE] 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    41
by (asm_simp_tac (prod_ss addsimps []) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    42
qed "BuildPair1";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    43
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    44
val rel_pair_cs = rel_cs addIs [BuildPair1] 
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    45
                         addEs [BreakPair1];
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    46
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    47
goalw Equiv.thy [refl_def,converse_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    48
    "!!A r. refl A r ==> r <= converse(r) O r";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    49
by (step_tac comp_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    50
by (dtac subsetD 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    51
by (assume_tac 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    52
by (etac SigmaE 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    53
by (rtac BreakPair1 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    54
by (fast_tac comp_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    55
qed "refl_comp_subset";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    56
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    57
goalw Equiv.thy [equiv_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    58
    "!!A r. equiv A r ==> converse(r) O r = r";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    59
by (rtac equalityI 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    60
by (REPEAT (ares_tac [sym_trans_comp_subset, refl_comp_subset] 1
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    61
     ORELSE etac conjE 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    62
qed "equiv_comp_eq";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    63
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    64
(*second half*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    65
goalw Equiv.thy [equiv_def,refl_def,sym_def,trans_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    66
    "!!A r. [| converse(r) O r = r;  Domain(r) = A |] ==> equiv A r";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    67
by (etac equalityE 1);
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    68
by (subgoal_tac "ALL x y. (x,y) : r --> (y,x) : r" 1);
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    69
by (safe_tac set_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    70
by (fast_tac (set_cs addSIs [converseI] addIs [compI]) 3);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    71
by (fast_tac (set_cs addSIs [converseI] addIs [compI] addSEs [DomainE]) 2);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    72
by (fast_tac (rel_pair_cs addSEs [SigmaE] addSIs [SigmaI]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    73
by (dtac subsetD 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    74
by (dtac subsetD 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    75
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    76
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    77
by flexflex_tac;
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    78
by (dtac subsetD 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    79
by (fast_tac converse_cs 2);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    80
by (fast_tac converse_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    81
qed "comp_equivI";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    82
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    83
(** Equivalence classes **)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    84
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    85
(*Lemma for the next result*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    86
goalw Equiv.thy [equiv_def,trans_def,sym_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    87
    "!!A r. [| equiv A r;  (a,b): r |] ==> r^^{a} <= r^^{b}";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    88
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    89
by (rtac ImageI 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    90
by (fast_tac rel_cs 2);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    91
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    92
qed "equiv_class_subset";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    93
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
    94
goal Equiv.thy "!!A r. [| equiv A r;  (a,b): r |] ==> r^^{a} = r^^{b}";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    95
by (REPEAT (ares_tac [equalityI, equiv_class_subset] 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    96
by (rewrite_goals_tac [equiv_def,sym_def]);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    97
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    98
qed "equiv_class_eq";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
    99
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   100
val prems = goalw Equiv.thy [equiv_def,refl_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   101
    "[| equiv A r;  a: A |] ==> a: r^^{a}";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   102
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   103
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   104
qed "equiv_class_self";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   105
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   106
(*Lemma for the next result*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   107
goalw Equiv.thy [equiv_def,refl_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   108
    "!!A r. [| equiv A r;  r^^{b} <= r^^{a};  b: A |] ==> (a,b): r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   109
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   110
qed "subset_equiv_class";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   111
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   112
val prems = goal Equiv.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   113
    "[| r^^{a} = r^^{b};  equiv A r;  b: A |] ==> (a,b): r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   114
by (REPEAT (resolve_tac (prems @ [equalityD2, subset_equiv_class]) 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   115
qed "eq_equiv_class";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   116
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   117
(*thus r^^{a} = r^^{b} as well*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   118
goalw Equiv.thy [equiv_def,trans_def,sym_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   119
    "!!A r. [| equiv A r;  x: (r^^{a} Int r^^{b}) |] ==> (a,b): r";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   120
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   121
qed "equiv_class_nondisjoint";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   122
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   123
val [major] = goalw Equiv.thy [equiv_def,refl_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   124
    "equiv A r ==> r <= Sigma A (%x.A)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   125
by (rtac (major RS conjunct1 RS conjunct1) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   126
qed "equiv_type";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   127
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   128
goal Equiv.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   129
    "!!A r. equiv A r ==> ((x,y): r) = (r^^{x} = r^^{y} & x:A & y:A)";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   130
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   131
by ((rtac equiv_class_eq 1) THEN (assume_tac 1) THEN (assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   132
by ((rtac eq_equiv_class 3) THEN 
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   133
    (assume_tac 4) THEN (assume_tac 4) THEN (assume_tac 3));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   134
by ((dtac equiv_type 1) THEN (dtac rev_subsetD 1) THEN
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   135
    (assume_tac 1) THEN (dtac SigmaD1 1) THEN (assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   136
by ((dtac equiv_type 1) THEN (dtac rev_subsetD 1) THEN
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   137
    (assume_tac 1) THEN (dtac SigmaD2 1) THEN (assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   138
qed "equiv_class_eq_iff";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   139
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   140
goal Equiv.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   141
    "!!A r. [| equiv A r;  x: A;  y: A |] ==> (r^^{x} = r^^{y}) = ((x,y): r)";
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   142
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   143
by ((rtac eq_equiv_class 1) THEN 
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   144
    (assume_tac 1) THEN (assume_tac 1) THEN (assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   145
by ((rtac equiv_class_eq 1) THEN 
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   146
    (assume_tac 1) THEN (assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   147
qed "eq_equiv_class_iff";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   148
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   149
(*** Quotients ***)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   150
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   151
(** Introduction/elimination rules -- needed? **)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   152
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   153
val prems = goalw Equiv.thy [quotient_def] "x:A ==> r^^{x}: A/r";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   154
by (rtac UN_I 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   155
by (resolve_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   156
by (rtac singletonI 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   157
qed "quotientI";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   158
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   159
val [major,minor] = goalw Equiv.thy [quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   160
    "[| X:(A/r);  !!x. [| X = r^^{x};  x:A |] ==> P |] 	\
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   161
\    ==> P";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   162
by (resolve_tac [major RS UN_E] 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   163
by (rtac minor 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   164
by (assume_tac 2);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   165
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   166
qed "quotientE";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   167
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   168
(** Not needed by Theory Integ --> bypassed **)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   169
(**goalw Equiv.thy [equiv_def,refl_def,quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   170
    "!!A r. equiv A r ==> Union(A/r) = A";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   171
by (fast_tac eq_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   172
qed "Union_quotient";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   173
**)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   174
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   175
(** Not needed by Theory Integ --> bypassed **)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   176
(*goalw Equiv.thy [quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   177
    "!!A r. [| equiv A r;  X: A/r;  Y: A/r |] ==> X=Y | (X Int Y <= 0)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   178
by (safe_tac (ZF_cs addSIs [equiv_class_eq]));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   179
by (assume_tac 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   180
by (rewrite_goals_tac [equiv_def,trans_def,sym_def]);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   181
by (fast_tac ZF_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   182
qed "quotient_disj";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   183
**)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   184
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   185
(**** Defining unary operations upon equivalence classes ****)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   186
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   187
(* theorem needed to prove UN_equiv_class *)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   188
goal Set.thy "!!A. [| a:A; ! y:A. b(y)=b(a) |] ==> (UN y:A. b(y))=b(a)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   189
by (fast_tac (eq_cs addSEs [equalityE]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   190
qed "UN_singleton_lemma";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   191
val UN_singleton = ballI RSN (2,UN_singleton_lemma);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   192
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   193
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   194
(** These proofs really require as local premises
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   195
     equiv A r;  congruent r b
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   196
**)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   197
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   198
(*Conversion rule*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   199
val prems as [equivA,bcong,_] = goal Equiv.thy
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   200
    "[| equiv A r;  congruent r b;  a: A |] ==> (UN x:r^^{a}. b(x)) = b(a)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   201
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   202
by (rtac UN_singleton 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   203
by (rtac equiv_class_self 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   204
by (assume_tac 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   205
by (assume_tac 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   206
by (rewrite_goals_tac [equiv_def,congruent_def,sym_def]);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   207
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   208
qed "UN_equiv_class";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   209
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   210
(*Resolve th against the "local" premises*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   211
val localize = RSLIST [equivA,bcong];
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   212
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   213
(*type checking of  UN x:r``{a}. b(x) *)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   214
val _::_::prems = goalw Equiv.thy [quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   215
    "[| equiv A r;  congruent r b;  X: A/r;	\
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   216
\	!!x.  x : A ==> b(x) : B |] 	\
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   217
\    ==> (UN x:X. b(x)) : B";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   218
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   219
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   220
by (rtac (localize UN_equiv_class RS ssubst) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   221
by (REPEAT (ares_tac prems 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   222
qed "UN_equiv_class_type";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   223
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   224
(*Sufficient conditions for injectiveness.  Could weaken premises!
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   225
  major premise could be an inclusion; bcong could be !!y. y:A ==> b(y):B
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   226
*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   227
val _::_::prems = goalw Equiv.thy [quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   228
    "[| equiv A r;   congruent r b;  \
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   229
\       (UN x:X. b(x))=(UN y:Y. b(y));  X: A/r;  Y: A/r;  \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   230
\       !!x y. [| x:A; y:A; b(x)=b(y) |] ==> (x,y):r |] 	\
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   231
\    ==> X=Y";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   232
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   233
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   234
by (rtac (equivA RS equiv_class_eq) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   235
by (REPEAT (ares_tac prems 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   236
by (etac box_equals 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   237
by (REPEAT (ares_tac [localize UN_equiv_class] 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   238
qed "UN_equiv_class_inject";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   239
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   240
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   241
(**** Defining binary operations upon equivalence classes ****)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   242
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   243
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   244
goalw Equiv.thy [congruent_def,congruent2_def,equiv_def,refl_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   245
    "!!A r. [| equiv A r;  congruent2 r b;  a: A |] ==> congruent r (b a)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   246
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   247
qed "congruent2_implies_congruent";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   248
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   249
val equivA::prems = goalw Equiv.thy [congruent_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   250
    "[| equiv A r;  congruent2 r b;  a: A |] ==> \
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   251
\    congruent r (%x1. UN x2:r^^{a}. b x1 x2)";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   252
by (cut_facts_tac (equivA::prems) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   253
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   254
by (rtac (equivA RS equiv_type RS subsetD RS SigmaE2) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   255
by (assume_tac 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   256
by (asm_simp_tac (prod_ss addsimps [equivA RS UN_equiv_class,
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   257
				 congruent2_implies_congruent]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   258
by (rewrite_goals_tac [congruent2_def,equiv_def,refl_def]);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   259
by (fast_tac rel_cs 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   260
qed "congruent2_implies_congruent_UN";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   261
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   262
val prems as equivA::_ = goal Equiv.thy
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   263
    "[| equiv A r;  congruent2 r b;  a1: A;  a2: A |]  \
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   264
\    ==> (UN x1:r^^{a1}. UN x2:r^^{a2}. b x1 x2) = b a1 a2";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   265
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   266
by (asm_simp_tac (prod_ss addsimps [equivA RS UN_equiv_class,
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   267
				    congruent2_implies_congruent,
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   268
				    congruent2_implies_congruent_UN]) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   269
qed "UN_equiv_class2";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   270
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   271
(*type checking*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   272
val prems = goalw Equiv.thy [quotient_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   273
    "[| equiv A r;  congruent2 r b;  \
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   274
\       X1: A/r;  X2: A/r;	\
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   275
\	!!x1 x2.  [| x1: A; x2: A |] ==> b x1 x2 : B |]    \
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   276
\    ==> (UN x1:X1. UN x2:X2. b x1 x2) : B";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   277
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   278
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   279
by (REPEAT (ares_tac (prems@[UN_equiv_class_type,
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   280
			     congruent2_implies_congruent_UN,
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   281
			     congruent2_implies_congruent, quotientI]) 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   282
qed "UN_equiv_class_type2";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   283
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   284
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   285
(*Suggested by John Harrison -- the two subproofs may be MUCH simpler
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   286
  than the direct proof*)
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   287
val prems = goalw Equiv.thy [congruent2_def,equiv_def,refl_def]
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   288
    "[| equiv A r;	\
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   289
\       !! y z w. [| w: A;  (y,z) : r |] ==> b y w = b z w;      \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   290
\       !! y z w. [| w: A;  (y,z) : r |] ==> b w y = b w z       \
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   291
\    |] ==> congruent2 r b";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   292
by (cut_facts_tac prems 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   293
by (safe_tac rel_cs);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   294
by (rtac trans 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   295
by (REPEAT (ares_tac prems 1
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   296
     ORELSE etac (subsetD RS SigmaE2) 1 THEN assume_tac 2 THEN assume_tac 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   297
qed "congruent2I";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   298
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   299
val [equivA,commute,congt] = goal Equiv.thy
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   300
    "[| equiv A r;	\
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   301
\       !! y z. [| y: A;  z: A |] ==> b y z = b z y;        \
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 925
diff changeset
   302
\       !! y z w. [| w: A;  (y,z): r |] ==> b w y = b w z	\
925
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   303
\    |] ==> congruent2 r b";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   304
by (resolve_tac [equivA RS congruent2I] 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   305
by (rtac (commute RS trans) 1);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   306
by (rtac (commute RS trans RS sym) 3);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   307
by (rtac sym 5);
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   308
by (REPEAT (ares_tac [congt] 1
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   309
     ORELSE etac (equivA RS equiv_type RS subsetD RS SigmaE2) 1));
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   310
qed "congruent2_commuteI";
15539deb6863 new version of HOL/Integ with curried function application
clasohm
parents:
diff changeset
   311