src/HOL/Relation.ML
author paulson
Wed, 15 Jul 1998 14:19:02 +0200
changeset 5148 74919e8f221c
parent 5143 b94cd208f073
child 5231 2a454140ae24
permissions -rw-r--r--
More tidying and removal of "\!\!... from Goal commands
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1454
diff changeset
     1
(*  Title:      Relation.ML
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
     3
    Authors:    Lawrence C Paulson, Cambridge University Computer Laboratory
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
     4
    Copyright   1996  University of Cambridge
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     5
*)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     6
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     7
open Relation;
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     8
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
     9
(** Identity relation **)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    10
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    11
Goalw [id_def] "(a,a) : id";  
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    12
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    13
qed "idI";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    14
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    15
val major::prems = goalw thy [id_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    16
    "[| p: id;  !!x.[| p = (x,x) |] ==> P  \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    17
\    |] ==>  P";  
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    18
by (rtac (major RS CollectE) 1);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    19
by (etac exE 1);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    20
by (eresolve_tac prems 1);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    21
qed "idE";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    22
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    23
Goalw [id_def] "(a,b):id = (a=b)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    24
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    25
qed "pair_in_id_conv";
1694
3452958f85a8 Added R_O_id and id_O_R
nipkow
parents: 1642
diff changeset
    26
Addsimps [pair_in_id_conv];
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    27
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    28
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    29
(** Composition of two relations **)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    30
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    31
Goalw [comp_def]
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    32
    "[| (a,b):s; (b,c):r |] ==> (a,c) : r O s";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    33
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    34
qed "compI";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    35
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    36
(*proof requires higher-level assumptions or a delaying of hyp_subst_tac*)
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    37
val prems = goalw thy [comp_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    38
    "[| xz : r O s;  \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    39
\       !!x y z. [| xz = (x,z);  (x,y):s;  (y,z):r |] ==> P \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    40
\    |] ==> P";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    41
by (cut_facts_tac prems 1);
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
    42
by (REPEAT (eresolve_tac [CollectE, splitE, exE, conjE] 1 
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
    43
     ORELSE ares_tac prems 1));
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    44
qed "compE";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    45
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    46
val prems = goal thy
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    47
    "[| (a,c) : r O s;  \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    48
\       !!y. [| (a,y):s;  (y,c):r |] ==> P \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    49
\    |] ==> P";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    50
by (rtac compE 1);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    51
by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Pair_inject,ssubst] 1));
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    52
qed "compEpair";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    53
1754
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1694
diff changeset
    54
AddIs [compI, idI];
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1694
diff changeset
    55
AddSEs [compE, idE];
852093aeb0ab Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1694
diff changeset
    56
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    57
Goal "R O id = R";
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    58
by (Fast_tac 1);
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    59
qed "R_O_id";
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    60
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    61
Goal "id O R = R";
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    62
by (Fast_tac 1);
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    63
qed "id_O_R";
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    64
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    65
Addsimps [R_O_id,id_O_R];
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    66
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
    67
Goal "(R O S) O T = R O (S O T)";
4830
bd73675adbed Added a few lemmas.
nipkow
parents: 4760
diff changeset
    68
by (Blast_tac 1);
bd73675adbed Added a few lemmas.
nipkow
parents: 4760
diff changeset
    69
qed "O_assoc";
bd73675adbed Added a few lemmas.
nipkow
parents: 4760
diff changeset
    70
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
    71
Goal "[| r'<=r; s'<=s |] ==> (r' O s') <= (r O s)";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    72
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    73
qed "comp_mono";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    74
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    75
Goal "[| s <= A Times B;  r <= B Times C |] ==> (r O s) <= A Times C";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    76
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    77
qed "comp_subset_Sigma";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    78
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    79
(** Natural deduction for trans(r) **)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    80
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
    81
val prems = goalw thy [trans_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    82
    "(!! x y z. [| (x,y):r;  (y,z):r |] ==> (x,z):r) ==> trans(r)";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    83
by (REPEAT (ares_tac (prems@[allI,impI]) 1));
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    84
qed "transI";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    85
5148
74919e8f221c More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5143
diff changeset
    86
Goalw [trans_def] "[| trans(r);  (a,b):r;  (b,c):r |] ==> (a,c):r";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
    87
by (Blast_tac 1);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    88
qed "transD";
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    89
3439
54785105178c converse -> ^-1
nipkow
parents: 3413
diff changeset
    90
(** Natural deduction for r^-1 **)
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
    91
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
    92
Goalw [converse_def] "((a,b): r^-1) = ((b,a):r)";
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
    93
by (Simp_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
    94
qed "converse_iff";
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
    95
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
    96
AddIffs [converse_iff];
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
    97
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
    98
Goalw [converse_def] "(a,b):r ==> (b,a): r^-1";
1264
3eb91524b938 added local simpsets; removed IOA from 'make test'
clasohm
parents: 1128
diff changeset
    99
by (Simp_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   100
qed "converseI";
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   101
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5069
diff changeset
   102
Goalw [converse_def] "(a,b) : r^-1 ==> (b,a) : r";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   103
by (Blast_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   104
qed "converseD";
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   105
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   106
(*More general than converseD, as it "splits" the member of the relation*)
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   107
qed_goalw "converseE" thy [converse_def]
3439
54785105178c converse -> ^-1
nipkow
parents: 3413
diff changeset
   108
    "[| yx : r^-1;  \
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   109
\       !!x y. [| yx=(y,x);  (x,y):r |] ==> P \
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   110
\    |] ==> P"
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   111
 (fn [major,minor]=>
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   112
  [ (rtac (major RS CollectE) 1),
1454
d0266c81a85e Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents: 1264
diff changeset
   113
    (REPEAT (eresolve_tac [splitE, bexE,exE, conjE, minor] 1)),
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   114
    (assume_tac 1) ]);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   115
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   116
AddSEs [converseE];
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   117
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   118
Goalw [converse_def] "(r^-1)^-1 = r";
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   119
by (Blast_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   120
qed "converse_converse";
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   121
Addsimps [converse_converse];
3413
c1f63cc3a768 Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents: 2891
diff changeset
   122
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   123
Goal "(r O s)^-1 = s^-1 O r^-1";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
   124
by (Blast_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   125
qed "converse_comp";
1605
248e1e125ca0 added converse_converse
nipkow
parents: 1552
diff changeset
   126
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   127
Goal "id^-1 = id";
4644
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   128
by (Blast_tac 1);
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   129
qed "converse_id";
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   130
Addsimps [converse_id];
4644
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   131
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   132
(** Domain **)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   133
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   134
qed_goalw "Domain_iff" thy [Domain_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   135
    "a: Domain(r) = (EX y. (a,y): r)"
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   136
 (fn _=> [ (Blast_tac 1) ]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   137
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   138
qed_goal "DomainI" thy "!!a b r. (a,b): r ==> a: Domain(r)"
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   139
 (fn _ => [ (etac (exI RS (Domain_iff RS iffD2)) 1) ]);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   140
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   141
qed_goal "DomainE" thy
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   142
    "[| a : Domain(r);  !!y. (a,y): r ==> P |] ==> P"
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   143
 (fn prems=>
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   144
  [ (rtac (Domain_iff RS iffD1 RS exE) 1),
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   145
    (REPEAT (ares_tac prems 1)) ]);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   146
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   147
AddIs  [DomainI];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   148
AddSEs [DomainE];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   149
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   150
Goal "Domain id = UNIV";
4644
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   151
by (Blast_tac 1);
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   152
qed "Domain_id";
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   153
Addsimps [Domain_id];
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   154
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   155
(** Range **)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   156
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   157
qed_goalw "RangeI" thy [Range_def] "!!a b r.(a,b): r ==> b : Range(r)"
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   158
 (fn _ => [ (etac (converseI RS DomainI) 1) ]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   159
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   160
qed_goalw "RangeE" thy [Range_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   161
    "[| b : Range(r);  !!x. (x,b): r ==> P |] ==> P"
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   162
 (fn major::prems=>
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   163
  [ (rtac (major RS DomainE) 1),
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   164
    (resolve_tac prems 1),
4746
a5dcd7e4a37d inverse -> converse
paulson
parents: 4733
diff changeset
   165
    (etac converseD 1) ]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   166
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   167
AddIs  [RangeI];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   168
AddSEs [RangeE];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   169
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   170
Goal "Range id = UNIV";
4644
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   171
by (Blast_tac 1);
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   172
qed "Range_id";
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   173
Addsimps [Range_id];
ecf8f17f6fe0 New laws for id
paulson
parents: 4601
diff changeset
   174
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   175
(*** Image of a set under a relation ***)
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   176
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   177
qed_goalw "Image_iff" thy [Image_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   178
    "b : r^^A = (? x:A. (x,b):r)"
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   179
 (fn _ => [ Blast_tac 1 ]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   180
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   181
qed_goalw "Image_singleton" thy [Image_def]
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   182
    "r^^{a} = {b. (a,b):r}"
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   183
 (fn _ => [ Blast_tac 1 ]);
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   184
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   185
qed_goal "Image_singleton_iff" thy
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   186
    "(b : r^^{a}) = ((a,b):r)"
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   187
 (fn _ => [ rtac (Image_iff RS trans) 1,
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   188
            Blast_tac 1 ]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   189
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   190
AddIffs [Image_singleton_iff];
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   191
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   192
qed_goalw "ImageI" thy [Image_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   193
    "!!a b r. [| (a,b): r;  a:A |] ==> b : r^^A"
2891
d8f254ad1ab9 Calls Blast_tac
paulson
parents: 2637
diff changeset
   194
 (fn _ => [ (Blast_tac 1)]);
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   195
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   196
qed_goalw "ImageE" thy [Image_def]
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   197
    "[| b: r^^A;  !!x.[| (x,b): r;  x:A |] ==> P |] ==> P"
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   198
 (fn major::prems=>
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   199
  [ (rtac (major RS CollectE) 1),
3718
d78cf498a88c Minor tidying to use Clarify_tac, etc.
paulson
parents: 3439
diff changeset
   200
    (Clarify_tac 1),
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   201
    (rtac (hd prems) 1),
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   202
    (REPEAT (etac bexE 1 ORELSE ares_tac prems 1)) ]);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   203
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   204
AddIs  [ImageI];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   205
AddSEs [ImageE];
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1842
diff changeset
   206
4593
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   207
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   208
qed_goal "Image_empty" thy
4593
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   209
    "R^^{} = {}"
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   210
 (fn _ => [ Blast_tac 1 ]);
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   211
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   212
Addsimps [Image_empty];
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   213
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   214
Goal "id ^^ A = A";
4601
87fc0d44b837 New theorem Image_id
paulson
parents: 4593
diff changeset
   215
by (Blast_tac 1);
87fc0d44b837 New theorem Image_id
paulson
parents: 4593
diff changeset
   216
qed "Image_id";
87fc0d44b837 New theorem Image_id
paulson
parents: 4593
diff changeset
   217
87fc0d44b837 New theorem Image_id
paulson
parents: 4593
diff changeset
   218
Addsimps [Image_id];
87fc0d44b837 New theorem Image_id
paulson
parents: 4593
diff changeset
   219
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   220
qed_goal "Image_Int_subset" thy
4593
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   221
    "R ^^ (A Int B) <= R ^^ A Int R ^^ B"
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   222
 (fn _ => [ Blast_tac 1 ]);
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   223
4733
2c984ac036f5 New theorem Image_eq_UN; deleted the silly vimage_inverse_Image
paulson
parents: 4673
diff changeset
   224
qed_goal "Image_Un" thy "R ^^ (A Un B) = R ^^ A Un R ^^ B"
4593
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   225
 (fn _ => [ Blast_tac 1 ]);
6fc8f224655f Three new facts about Image
paulson
parents: 4423
diff changeset
   226
4733
2c984ac036f5 New theorem Image_eq_UN; deleted the silly vimage_inverse_Image
paulson
parents: 4673
diff changeset
   227
qed_goal "Image_subset" thy "!!A B r. r <= A Times B ==> r^^C <= B"
1128
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   228
 (fn _ =>
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   229
  [ (rtac subsetI 1),
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   230
    (REPEAT (eresolve_tac [asm_rl, ImageE, subsetD RS SigmaD2] 1)) ]);
64b30e3cc6d4 Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff changeset
   231
4733
2c984ac036f5 New theorem Image_eq_UN; deleted the silly vimage_inverse_Image
paulson
parents: 4673
diff changeset
   232
(*NOT suitable for rewriting*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4830
diff changeset
   233
Goal "r^^B = (UN y: B. r^^{y})";
4673
59d80bacee62 New theorems; tidied
paulson
parents: 4650
diff changeset
   234
by (Blast_tac 1);
4733
2c984ac036f5 New theorem Image_eq_UN; deleted the silly vimage_inverse_Image
paulson
parents: 4673
diff changeset
   235
qed "Image_eq_UN";
4760
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   236
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   237
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   238
section "Univalent";
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   239
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   240
qed_goalw "UnivalentI" Relation.thy [Univalent_def] 
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   241
   "!!r. !x y. (x,y):r --> (!z. (x,z):r --> y=z) ==> Univalent r" (K [atac 1]);
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   242
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   243
qed_goalw "UnivalentD" Relation.thy [Univalent_def] 
9cdbd5a1d25a added introduction and elimination rules for Univalent
oheimb
parents: 4746
diff changeset
   244
	"!!r. [| Univalent r; (x,y):r; (x,z):r|] ==> y=z" (K [Auto_tac]);