src/HOL/Integ/Relation.ML
author wenzelm
Thu Jan 23 14:19:16 1997 +0100 (1997-01-23)
changeset 2545 d10abc8c11fb
parent 972 e61b058d58d2
permissions -rw-r--r--
added AxClasses test;
clasohm@925
     1
(*  Title: 	Relation.ML
clasohm@925
     2
    ID:         $Id$
clasohm@925
     3
    Authors: 	Riccardo Mattolini, Dip. Sistemi e Informatica
clasohm@925
     4
        	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@925
     5
    Copyright   1994 Universita' di Firenze
clasohm@925
     6
    Copyright   1993  University of Cambridge
clasohm@925
     7
clasohm@925
     8
Functions represented as relations in HOL Set Theory 
clasohm@925
     9
*)
clasohm@925
    10
clasohm@925
    11
val RSLIST = curry (op MRS);
clasohm@925
    12
clasohm@925
    13
open Relation;
clasohm@925
    14
clasohm@972
    15
goalw Relation.thy [converse_def] "!!a b r. (a,b):r ==> (b,a):converse(r)";
clasohm@925
    16
by (simp_tac prod_ss 1);
clasohm@925
    17
by (fast_tac set_cs 1);
clasohm@925
    18
qed "converseI";
clasohm@925
    19
clasohm@972
    20
goalw Relation.thy [converse_def] "!!a b r. (a,b) : converse(r) ==> (b,a) : r";
clasohm@925
    21
by (fast_tac comp_cs 1);
clasohm@925
    22
qed "converseD";
clasohm@925
    23
clasohm@925
    24
qed_goalw "converseE" Relation.thy [converse_def]
clasohm@925
    25
    "[| yx : converse(r);  \
clasohm@972
    26
\       !!x y. [| yx=(y,x);  (x,y):r |] ==> P \
clasohm@925
    27
\    |] ==> P"
clasohm@925
    28
 (fn [major,minor]=>
clasohm@925
    29
  [ (rtac (major RS CollectE) 1),
clasohm@925
    30
    (REPEAT (eresolve_tac [bexE,exE, conjE, minor] 1)),
clasohm@925
    31
    (hyp_subst_tac 1),
clasohm@925
    32
    (assume_tac 1) ]);
clasohm@925
    33
clasohm@925
    34
val converse_cs = comp_cs addSIs [converseI] 
clasohm@925
    35
			  addSEs [converseD,converseE];
clasohm@925
    36
clasohm@925
    37
qed_goalw "Domain_iff" Relation.thy [Domain_def]
clasohm@972
    38
    "a: Domain(r) = (EX y. (a,y): r)"
clasohm@925
    39
 (fn _=> [ (fast_tac comp_cs 1) ]);
clasohm@925
    40
clasohm@972
    41
qed_goal "DomainI" Relation.thy "!!a b r. (a,b): r ==> a: Domain(r)"
clasohm@925
    42
 (fn _ => [ (etac (exI RS (Domain_iff RS iffD2)) 1) ]);
clasohm@925
    43
clasohm@925
    44
qed_goal "DomainE" Relation.thy
clasohm@972
    45
    "[| a : Domain(r);  !!y. (a,y): r ==> P |] ==> P"
clasohm@925
    46
 (fn prems=>
clasohm@925
    47
  [ (rtac (Domain_iff RS iffD1 RS exE) 1),
clasohm@925
    48
    (REPEAT (ares_tac prems 1)) ]);
clasohm@925
    49
clasohm@972
    50
qed_goalw "RangeI" Relation.thy [Range_def] "!!a b r.(a,b): r ==> b : Range(r)"
clasohm@925
    51
 (fn _ => [ (etac (converseI RS DomainI) 1) ]);
clasohm@925
    52
clasohm@925
    53
qed_goalw "RangeE" Relation.thy [Range_def]
clasohm@972
    54
    "[| b : Range(r);  !!x. (x,b): r ==> P |] ==> P"
clasohm@925
    55
 (fn major::prems=>
clasohm@925
    56
  [ (rtac (major RS DomainE) 1),
clasohm@925
    57
    (resolve_tac prems 1),
clasohm@925
    58
    (etac converseD 1) ]);
clasohm@925
    59
clasohm@925
    60
(*** Image of a set under a function/relation ***)
clasohm@925
    61
clasohm@925
    62
qed_goalw "Image_iff" Relation.thy [Image_def]
clasohm@972
    63
    "b : r^^A = (? x:A. (x,b):r)"
clasohm@925
    64
 (fn _ => [ fast_tac (comp_cs addIs [RangeI]) 1 ]);
clasohm@925
    65
clasohm@925
    66
qed_goal "Image_singleton_iff" Relation.thy
clasohm@972
    67
    "(b : r^^{a}) = ((a,b):r)"
clasohm@925
    68
 (fn _ => [ rtac (Image_iff RS trans) 1,
clasohm@925
    69
	    fast_tac comp_cs 1 ]);
clasohm@925
    70
clasohm@925
    71
qed_goalw "ImageI" Relation.thy [Image_def]
clasohm@972
    72
    "!!a b r. [| (a,b): r;  a:A |] ==> b : r^^A"
clasohm@925
    73
 (fn _ => [ (REPEAT (ares_tac [CollectI,RangeI,bexI] 1)),
clasohm@925
    74
            (resolve_tac [conjI ] 1),
clasohm@925
    75
            (resolve_tac [RangeI] 1),
clasohm@925
    76
            (REPEAT (fast_tac set_cs 1))]);
clasohm@925
    77
clasohm@925
    78
qed_goalw "ImageE" Relation.thy [Image_def]
clasohm@972
    79
    "[| b: r^^A;  !!x.[| (x,b): r;  x:A |] ==> P |] ==> P"
clasohm@925
    80
 (fn major::prems=>
clasohm@925
    81
  [ (rtac (major RS CollectE) 1),
clasohm@925
    82
    (safe_tac set_cs),
clasohm@925
    83
    (etac RangeE 1),
clasohm@925
    84
    (rtac (hd prems) 1),
clasohm@925
    85
    (REPEAT (etac bexE 1 ORELSE ares_tac prems 1)) ]);
clasohm@925
    86
clasohm@925
    87
qed_goal "Image_subset" Relation.thy
clasohm@925
    88
    "!!A B r. r <= Sigma A (%x.B) ==> r^^C <= B"
clasohm@925
    89
 (fn _ =>
clasohm@925
    90
  [ (rtac subsetI 1),
clasohm@925
    91
    (REPEAT (eresolve_tac [asm_rl, ImageE, subsetD RS SigmaD2] 1)) ]);
clasohm@925
    92
clasohm@925
    93
val rel_cs = converse_cs addSIs [converseI] 
clasohm@925
    94
                         addIs  [ImageI, DomainI, RangeI]
clasohm@925
    95
                         addSEs [ImageE, DomainE, RangeE];
clasohm@925
    96
clasohm@925
    97
val rel_eq_cs = rel_cs addSIs [equalityI];
clasohm@925
    98