Trancl is now based on Relation which used to be in Integ.
authornipkow
Fri May 26 18:11:47 1995 +0200 (1995-05-26)
changeset 112864b30e3cc6d4
parent 1127 42ec82147d83
child 1129 866fff857626
Trancl is now based on Relation which used to be in Integ.
src/HOL/Relation.ML
src/HOL/Relation.thy
src/HOL/Trancl.ML
src/HOL/Trancl.thy
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Relation.ML	Fri May 26 18:11:47 1995 +0200
     1.3 @@ -0,0 +1,173 @@
     1.4 +(*  Title: 	Relation.ML
     1.5 +    ID:         $Id$
     1.6 +    Authors: 	Riccardo Mattolini, Dip. Sistemi e Informatica
     1.7 +        	Lawrence C Paulson, Cambridge University Computer Laboratory
     1.8 +    Copyright   1994 Universita' di Firenze
     1.9 +    Copyright   1993  University of Cambridge
    1.10 +*)
    1.11 +
    1.12 +val RSLIST = curry (op MRS);
    1.13 +
    1.14 +open Relation;
    1.15 +
    1.16 +(** Identity relation **)
    1.17 +
    1.18 +goalw Relation.thy [id_def] "(a,a) : id";  
    1.19 +by (rtac CollectI 1);
    1.20 +by (rtac exI 1);
    1.21 +by (rtac refl 1);
    1.22 +qed "idI";
    1.23 +
    1.24 +val major::prems = goalw Relation.thy [id_def]
    1.25 +    "[| p: id;  !!x.[| p = (x,x) |] ==> P  \
    1.26 +\    |] ==>  P";  
    1.27 +by (rtac (major RS CollectE) 1);
    1.28 +by (etac exE 1);
    1.29 +by (eresolve_tac prems 1);
    1.30 +qed "idE";
    1.31 +
    1.32 +goalw Relation.thy [id_def] "(a,b):id = (a=b)";
    1.33 +by(fast_tac prod_cs 1);
    1.34 +qed "pair_in_id_conv";
    1.35 +
    1.36 +
    1.37 +(** Composition of two relations **)
    1.38 +
    1.39 +val prems = goalw Relation.thy [comp_def]
    1.40 +    "[| (a,b):s; (b,c):r |] ==> (a,c) : r O s";
    1.41 +by (fast_tac (set_cs addIs prems) 1);
    1.42 +qed "compI";
    1.43 +
    1.44 +(*proof requires higher-level assumptions or a delaying of hyp_subst_tac*)
    1.45 +val prems = goalw Relation.thy [comp_def]
    1.46 +    "[| xz : r O s;  \
    1.47 +\       !!x y z. [| xz = (x,z);  (x,y):s;  (y,z):r |] ==> P \
    1.48 +\    |] ==> P";
    1.49 +by (cut_facts_tac prems 1);
    1.50 +by (REPEAT (eresolve_tac [CollectE, exE, conjE] 1 ORELSE ares_tac prems 1));
    1.51 +qed "compE";
    1.52 +
    1.53 +val prems = goal Relation.thy
    1.54 +    "[| (a,c) : r O s;  \
    1.55 +\       !!y. [| (a,y):s;  (y,c):r |] ==> P \
    1.56 +\    |] ==> P";
    1.57 +by (rtac compE 1);
    1.58 +by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Pair_inject,ssubst] 1));
    1.59 +qed "compEpair";
    1.60 +
    1.61 +val comp_cs = prod_cs addIs [compI, idI] addSEs [compE, idE];
    1.62 +
    1.63 +goal Relation.thy "!!r s. [| r'<=r; s'<=s |] ==> (r' O s') <= (r O s)";
    1.64 +by (fast_tac comp_cs 1);
    1.65 +qed "comp_mono";
    1.66 +
    1.67 +goal Relation.thy
    1.68 +    "!!r s. [| s <= Sigma A (%x.B);  r <= Sigma B (%x.C) |] ==> \
    1.69 +\           (r O s) <= Sigma A (%x.C)";
    1.70 +by (fast_tac comp_cs 1);
    1.71 +qed "comp_subset_Sigma";
    1.72 +
    1.73 +(** Natural deduction for trans(r) **)
    1.74 +
    1.75 +val prems = goalw Relation.thy [trans_def]
    1.76 +    "(!! x y z. [| (x,y):r;  (y,z):r |] ==> (x,z):r) ==> trans(r)";
    1.77 +by (REPEAT (ares_tac (prems@[allI,impI]) 1));
    1.78 +qed "transI";
    1.79 +
    1.80 +val major::prems = goalw Relation.thy [trans_def]
    1.81 +    "[| trans(r);  (a,b):r;  (b,c):r |] ==> (a,c):r";
    1.82 +by (cut_facts_tac [major] 1);
    1.83 +by (fast_tac (HOL_cs addIs prems) 1);
    1.84 +qed "transD";
    1.85 +
    1.86 +(** Natural deduction for converse(r) **)
    1.87 +
    1.88 +goalw Relation.thy [converse_def] "!!a b r. (a,b):r ==> (b,a):converse(r)";
    1.89 +by (simp_tac prod_ss 1);
    1.90 +by (fast_tac set_cs 1);
    1.91 +qed "converseI";
    1.92 +
    1.93 +goalw Relation.thy [converse_def] "!!a b r. (a,b) : converse(r) ==> (b,a) : r";
    1.94 +by (fast_tac comp_cs 1);
    1.95 +qed "converseD";
    1.96 +
    1.97 +qed_goalw "converseE" Relation.thy [converse_def]
    1.98 +    "[| yx : converse(r);  \
    1.99 +\       !!x y. [| yx=(y,x);  (x,y):r |] ==> P \
   1.100 +\    |] ==> P"
   1.101 + (fn [major,minor]=>
   1.102 +  [ (rtac (major RS CollectE) 1),
   1.103 +    (REPEAT (eresolve_tac [bexE,exE, conjE, minor] 1)),
   1.104 +    (hyp_subst_tac 1),
   1.105 +    (assume_tac 1) ]);
   1.106 +
   1.107 +val converse_cs = comp_cs addSIs [converseI] 
   1.108 +			  addSEs [converseD,converseE];
   1.109 +
   1.110 +(** Domain **)
   1.111 +
   1.112 +qed_goalw "Domain_iff" Relation.thy [Domain_def]
   1.113 +    "a: Domain(r) = (EX y. (a,y): r)"
   1.114 + (fn _=> [ (fast_tac comp_cs 1) ]);
   1.115 +
   1.116 +qed_goal "DomainI" Relation.thy "!!a b r. (a,b): r ==> a: Domain(r)"
   1.117 + (fn _ => [ (etac (exI RS (Domain_iff RS iffD2)) 1) ]);
   1.118 +
   1.119 +qed_goal "DomainE" Relation.thy
   1.120 +    "[| a : Domain(r);  !!y. (a,y): r ==> P |] ==> P"
   1.121 + (fn prems=>
   1.122 +  [ (rtac (Domain_iff RS iffD1 RS exE) 1),
   1.123 +    (REPEAT (ares_tac prems 1)) ]);
   1.124 +
   1.125 +(** Range **)
   1.126 +
   1.127 +qed_goalw "RangeI" Relation.thy [Range_def] "!!a b r.(a,b): r ==> b : Range(r)"
   1.128 + (fn _ => [ (etac (converseI RS DomainI) 1) ]);
   1.129 +
   1.130 +qed_goalw "RangeE" Relation.thy [Range_def]
   1.131 +    "[| b : Range(r);  !!x. (x,b): r ==> P |] ==> P"
   1.132 + (fn major::prems=>
   1.133 +  [ (rtac (major RS DomainE) 1),
   1.134 +    (resolve_tac prems 1),
   1.135 +    (etac converseD 1) ]);
   1.136 +
   1.137 +(*** Image of a set under a relation ***)
   1.138 +
   1.139 +qed_goalw "Image_iff" Relation.thy [Image_def]
   1.140 +    "b : r^^A = (? x:A. (x,b):r)"
   1.141 + (fn _ => [ fast_tac (comp_cs addIs [RangeI]) 1 ]);
   1.142 +
   1.143 +qed_goal "Image_singleton_iff" Relation.thy
   1.144 +    "(b : r^^{a}) = ((a,b):r)"
   1.145 + (fn _ => [ rtac (Image_iff RS trans) 1,
   1.146 +	    fast_tac comp_cs 1 ]);
   1.147 +
   1.148 +qed_goalw "ImageI" Relation.thy [Image_def]
   1.149 +    "!!a b r. [| (a,b): r;  a:A |] ==> b : r^^A"
   1.150 + (fn _ => [ (REPEAT (ares_tac [CollectI,RangeI,bexI] 1)),
   1.151 +            (resolve_tac [conjI ] 1),
   1.152 +            (resolve_tac [RangeI] 1),
   1.153 +            (REPEAT (fast_tac set_cs 1))]);
   1.154 +
   1.155 +qed_goalw "ImageE" Relation.thy [Image_def]
   1.156 +    "[| b: r^^A;  !!x.[| (x,b): r;  x:A |] ==> P |] ==> P"
   1.157 + (fn major::prems=>
   1.158 +  [ (rtac (major RS CollectE) 1),
   1.159 +    (safe_tac set_cs),
   1.160 +    (etac RangeE 1),
   1.161 +    (rtac (hd prems) 1),
   1.162 +    (REPEAT (etac bexE 1 ORELSE ares_tac prems 1)) ]);
   1.163 +
   1.164 +qed_goal "Image_subset" Relation.thy
   1.165 +    "!!A B r. r <= Sigma A (%x.B) ==> r^^C <= B"
   1.166 + (fn _ =>
   1.167 +  [ (rtac subsetI 1),
   1.168 +    (REPEAT (eresolve_tac [asm_rl, ImageE, subsetD RS SigmaD2] 1)) ]);
   1.169 +
   1.170 +val rel_cs = converse_cs addSIs [converseI] 
   1.171 +                         addIs  [ImageI, DomainI, RangeI]
   1.172 +                         addSEs [ImageE, DomainE, RangeE];
   1.173 +
   1.174 +val rel_eq_cs = rel_cs addSIs [equalityI];
   1.175 +
   1.176 +val rel_ss = prod_ss addsimps [pair_in_id_conv];
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/HOL/Relation.thy	Fri May 26 18:11:47 1995 +0200
     2.3 @@ -0,0 +1,27 @@
     2.4 +(*  Title: 	Relation.thy
     2.5 +    ID:         $Id$
     2.6 +    Author: 	Riccardo Mattolini, Dip. Sistemi e Informatica
     2.7 +        and	Lawrence C Paulson, Cambridge University Computer Laboratory
     2.8 +    Copyright   1994 Universita' di Firenze
     2.9 +    Copyright   1993  University of Cambridge
    2.10 +*)
    2.11 +
    2.12 +Relation = Prod +
    2.13 +consts
    2.14 +    id	        :: "('a * 'a)set"               (*the identity relation*)
    2.15 +    O	        :: "[('b * 'c)set, ('a * 'b)set] => ('a * 'c)set" (infixr 60)
    2.16 +    trans       :: "('a * 'a)set => bool" 	(*transitivity predicate*)
    2.17 +    converse    :: "('a*'a) set => ('a*'a) set"
    2.18 +    "^^"        :: "[('a*'a) set,'a set] => 'a set" (infixl 90)
    2.19 +    Domain      :: "('a*'a) set => 'a set"
    2.20 +    Range       :: "('a*'a) set => 'a set"
    2.21 +defs
    2.22 +    id_def	"id == {p. ? x. p = (x,x)}"
    2.23 +    comp_def	(*composition of relations*)
    2.24 +		"r O s == {xz. ? x y z. xz = (x,z) & (x,y):s & (y,z):r}"
    2.25 +    trans_def	  "trans(r) == (!x y z. (x,y):r --> (y,z):r --> (x,z):r)"
    2.26 +    converse_def  "converse(r) == {z. (? w:r. ? x y. w=(x,y) & z=(y,x))}"
    2.27 +    Domain_def    "Domain(r) == {z. ! x. (z=x --> (? y. (x,y):r))}"
    2.28 +    Range_def     "Range(r) == Domain(converse(r))"
    2.29 +    Image_def     "r ^^ s == {y. y:Range(r) &  (? x:s. (x,y):r)}"
    2.30 +end
     3.1 --- a/src/HOL/Trancl.ML	Fri May 26 11:20:08 1995 +0200
     3.2 +++ b/src/HOL/Trancl.ML	Fri May 26 18:11:47 1995 +0200
     3.3 @@ -8,76 +8,6 @@
     3.4  
     3.5  open Trancl;
     3.6  
     3.7 -(** Natural deduction for trans(r) **)
     3.8 -
     3.9 -val prems = goalw Trancl.thy [trans_def]
    3.10 -    "(!! x y z. [| (x,y):r;  (y,z):r |] ==> (x,z):r) ==> trans(r)";
    3.11 -by (REPEAT (ares_tac (prems@[allI,impI]) 1));
    3.12 -qed "transI";
    3.13 -
    3.14 -val major::prems = goalw Trancl.thy [trans_def]
    3.15 -    "[| trans(r);  (a,b):r;  (b,c):r |] ==> (a,c):r";
    3.16 -by (cut_facts_tac [major] 1);
    3.17 -by (fast_tac (HOL_cs addIs prems) 1);
    3.18 -qed "transD";
    3.19 -
    3.20 -(** Identity relation **)
    3.21 -
    3.22 -goalw Trancl.thy [id_def] "(a,a) : id";  
    3.23 -by (rtac CollectI 1);
    3.24 -by (rtac exI 1);
    3.25 -by (rtac refl 1);
    3.26 -qed "idI";
    3.27 -
    3.28 -val major::prems = goalw Trancl.thy [id_def]
    3.29 -    "[| p: id;  !!x.[| p = (x,x) |] ==> P  \
    3.30 -\    |] ==>  P";  
    3.31 -by (rtac (major RS CollectE) 1);
    3.32 -by (etac exE 1);
    3.33 -by (eresolve_tac prems 1);
    3.34 -qed "idE";
    3.35 -
    3.36 -goalw Trancl.thy [id_def] "(a,b):id = (a=b)";
    3.37 -by(fast_tac prod_cs 1);
    3.38 -qed "pair_in_id_conv";
    3.39 -
    3.40 -(** Composition of two relations **)
    3.41 -
    3.42 -val prems = goalw Trancl.thy [comp_def]
    3.43 -    "[| (a,b):s; (b,c):r |] ==> (a,c) : r O s";
    3.44 -by (fast_tac (set_cs addIs prems) 1);
    3.45 -qed "compI";
    3.46 -
    3.47 -(*proof requires higher-level assumptions or a delaying of hyp_subst_tac*)
    3.48 -val prems = goalw Trancl.thy [comp_def]
    3.49 -    "[| xz : r O s;  \
    3.50 -\       !!x y z. [| xz = (x,z);  (x,y):s;  (y,z):r |] ==> P \
    3.51 -\    |] ==> P";
    3.52 -by (cut_facts_tac prems 1);
    3.53 -by (REPEAT (eresolve_tac [CollectE, exE, conjE] 1 ORELSE ares_tac prems 1));
    3.54 -qed "compE";
    3.55 -
    3.56 -val prems = goal Trancl.thy
    3.57 -    "[| (a,c) : r O s;  \
    3.58 -\       !!y. [| (a,y):s;  (y,c):r |] ==> P \
    3.59 -\    |] ==> P";
    3.60 -by (rtac compE 1);
    3.61 -by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Pair_inject,ssubst] 1));
    3.62 -qed "compEpair";
    3.63 -
    3.64 -val comp_cs = prod_cs addIs [compI, idI] addSEs [compE, idE];
    3.65 -
    3.66 -goal Trancl.thy "!!r s. [| r'<=r; s'<=s |] ==> (r' O s') <= (r O s)";
    3.67 -by (fast_tac comp_cs 1);
    3.68 -qed "comp_mono";
    3.69 -
    3.70 -goal Trancl.thy
    3.71 -    "!!r s. [| s <= Sigma A (%x.B);  r <= Sigma B (%x.C) |] ==> \
    3.72 -\           (r O s) <= Sigma A (%x.C)";
    3.73 -by (fast_tac comp_cs 1);
    3.74 -qed "comp_subset_Sigma";
    3.75 -
    3.76 -
    3.77  (** The relation rtrancl **)
    3.78  
    3.79  goal Trancl.thy "mono(%s. id Un (r O s))";
    3.80 @@ -90,14 +20,14 @@
    3.81  (*Reflexivity of rtrancl*)
    3.82  goal Trancl.thy "(a,a) : r^*";
    3.83  by (stac rtrancl_unfold 1);
    3.84 -by (fast_tac comp_cs 1);
    3.85 +by (fast_tac rel_cs 1);
    3.86  qed "rtrancl_refl";
    3.87  
    3.88  (*Closure under composition with r*)
    3.89  val prems = goal Trancl.thy
    3.90      "[| (a,b) : r^*;  (b,c) : r |] ==> (a,c) : r^*";
    3.91  by (stac rtrancl_unfold 1);
    3.92 -by (fast_tac (comp_cs addIs prems) 1);
    3.93 +by (fast_tac (rel_cs addIs prems) 1);
    3.94  qed "rtrancl_into_rtrancl";
    3.95  
    3.96  (*rtrancl of r contains r*)
    3.97 @@ -119,7 +49,7 @@
    3.98  \     !!x y z.[| P((x,y)); (x,y): r^*; (y,z): r |]  ==>  P((x,z)) |] \
    3.99  \  ==>  P((a,b))";
   3.100  by (rtac ([rtrancl_def, rtrancl_fun_mono, major] MRS def_induct) 1);
   3.101 -by (fast_tac (comp_cs addIs prems) 1);
   3.102 +by (fast_tac (rel_cs addIs prems) 1);
   3.103  qed "rtrancl_full_induct";
   3.104  
   3.105  (*nice induction rule*)
   3.106 @@ -134,8 +64,8 @@
   3.107  by (fast_tac HOL_cs 1);
   3.108  (*now do the induction*)
   3.109  by (resolve_tac [major RS rtrancl_full_induct] 1);
   3.110 -by (fast_tac (comp_cs addIs prems) 1);
   3.111 -by (fast_tac (comp_cs addIs prems) 1);
   3.112 +by (fast_tac (rel_cs addIs prems) 1);
   3.113 +by (fast_tac (rel_cs addIs prems) 1);
   3.114  qed "rtrancl_induct";
   3.115  
   3.116  (*transitivity of transitive closure!! -- by induction.*)
   3.117 @@ -199,8 +129,8 @@
   3.118  by (REPEAT (eresolve_tac ([asm_rl,disjE,exE,conjE]@prems) 1));
   3.119  by (rtac (rewrite_rule [trancl_def] major RS compEpair) 1);
   3.120  by (etac rtranclE 1);
   3.121 -by (fast_tac comp_cs 1);
   3.122 -by (fast_tac (comp_cs addSIs [rtrancl_into_trancl1]) 1);
   3.123 +by (fast_tac rel_cs 1);
   3.124 +by (fast_tac (rel_cs addSIs [rtrancl_into_trancl1]) 1);
   3.125  qed "tranclE";
   3.126  
   3.127  (*Transitivity of r^+.
   3.128 @@ -237,12 +167,10 @@
   3.129  by (cut_facts_tac prems 1);
   3.130  by (rtac (major RS rtrancl_induct) 1);
   3.131  by (rtac (refl RS disjI1) 1);
   3.132 -by (fast_tac (comp_cs addSEs [SigmaE2]) 1);
   3.133 +by (fast_tac (rel_cs addSEs [SigmaE2]) 1);
   3.134  qed "trancl_subset_Sigma_lemma";
   3.135  
   3.136  goalw Trancl.thy [trancl_def]
   3.137      "!!r. r <= Sigma A (%x.A) ==> trancl(r) <= Sigma A (%x.A)";
   3.138 -by (fast_tac (comp_cs addSDs [trancl_subset_Sigma_lemma]) 1);
   3.139 +by (fast_tac (rel_cs addSDs [trancl_subset_Sigma_lemma]) 1);
   3.140  qed "trancl_subset_Sigma";
   3.141 -
   3.142 -val prod_ss = prod_ss addsimps [pair_in_id_conv];
     4.1 --- a/src/HOL/Trancl.thy	Fri May 26 11:20:08 1995 +0200
     4.2 +++ b/src/HOL/Trancl.thy	Fri May 26 18:11:47 1995 +0200
     4.3 @@ -3,24 +3,16 @@
     4.4      Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     4.5      Copyright   1992  University of Cambridge
     4.6  
     4.7 -Transitive closure of a relation
     4.8 +Relfexive and Transitive closure of a relation
     4.9  
    4.10 -rtrancl is refl/transitive closure;  trancl is transitive closure
    4.11 +rtrancl is refl&transitive closure;  trancl is transitive closure
    4.12  *)
    4.13  
    4.14 -Trancl = Lfp + Prod + 
    4.15 +Trancl = Lfp + Relation + 
    4.16  consts
    4.17 -    trans   :: "('a * 'a)set => bool" 	(*transitivity predicate*)
    4.18 -    id	    :: "('a * 'a)set"
    4.19      rtrancl :: "('a * 'a)set => ('a * 'a)set"	("(_^*)" [100] 100)
    4.20      trancl  :: "('a * 'a)set => ('a * 'a)set"	("(_^+)" [100] 100)  
    4.21 -    O	    :: "[('b * 'c)set, ('a * 'b)set] => ('a * 'c)set" (infixr 60)
    4.22  defs   
    4.23 -trans_def	"trans(r) == (!x y z. (x,y):r --> (y,z):r --> (x,z):r)"
    4.24 -comp_def	(*composition of relations*)
    4.25 -		"r O s == {xz. ? x y z. xz = (x,z) & (x,y):s & (y,z):r}"
    4.26 -id_def		(*the identity relation*)
    4.27 -		"id == {p. ? x. p = (x,x)}"
    4.28  rtrancl_def	"r^* == lfp(%s. id Un (r O s))"
    4.29  trancl_def	"r^+ == r O rtrancl(r)"
    4.30  end