src/ZF/OrderArith.thy
changeset 13140 6d97dbb189a9
parent 9883 c1c8647af477
child 13269 3ba9be497c33
     1.1 --- a/src/ZF/OrderArith.thy	Sat May 11 20:40:31 2002 +0200
     1.2 +++ b/src/ZF/OrderArith.thy	Mon May 13 09:02:13 2002 +0200
     1.3 @@ -6,31 +6,507 @@
     1.4  Towards ordinal arithmetic.  Also useful with wfrec.
     1.5  *)
     1.6  
     1.7 -OrderArith = Order + Sum + Ordinal +
     1.8 -consts
     1.9 -  radd, rmult      :: [i,i,i,i]=>i
    1.10 -  rvimage          :: [i,i,i]=>i
    1.11 +theory OrderArith = Order + Sum + Ordinal:
    1.12 +constdefs
    1.13  
    1.14 -defs
    1.15    (*disjoint sum of two relations; underlies ordinal addition*)
    1.16 -  radd_def "radd(A,r,B,s) == 
    1.17 +  radd    :: "[i,i,i,i]=>i"
    1.18 +    "radd(A,r,B,s) == 
    1.19                  {z: (A+B) * (A+B).  
    1.20                      (EX x y. z = <Inl(x), Inr(y)>)   |   
    1.21                      (EX x' x. z = <Inl(x'), Inl(x)> & <x',x>:r)   |      
    1.22                      (EX y' y. z = <Inr(y'), Inr(y)> & <y',y>:s)}"
    1.23  
    1.24    (*lexicographic product of two relations; underlies ordinal multiplication*)
    1.25 -  rmult_def "rmult(A,r,B,s) == 
    1.26 +  rmult   :: "[i,i,i,i]=>i"
    1.27 +    "rmult(A,r,B,s) == 
    1.28                  {z: (A*B) * (A*B).  
    1.29                      EX x' y' x y. z = <<x',y'>, <x,y>> &         
    1.30                         (<x',x>: r | (x'=x & <y',y>: s))}"
    1.31  
    1.32    (*inverse image of a relation*)
    1.33 -  rvimage_def "rvimage(A,f,r) == {z: A*A. EX x y. z = <x,y> & <f`x,f`y>: r}"
    1.34 +  rvimage :: "[i,i,i]=>i"
    1.35 +    "rvimage(A,f,r) == {z: A*A. EX x y. z = <x,y> & <f`x,f`y>: r}"
    1.36 +
    1.37 +  measure :: "[i, i\<Rightarrow>i] \<Rightarrow> i"
    1.38 +    "measure(A,f) == {<x,y>: A*A. f(x) < f(y)}"
    1.39 +
    1.40 +
    1.41 +(**** Addition of relations -- disjoint sum ****)
    1.42 +
    1.43 +(** Rewrite rules.  Can be used to obtain introduction rules **)
    1.44 +
    1.45 +lemma radd_Inl_Inr_iff [iff]: 
    1.46 +    "<Inl(a), Inr(b)> : radd(A,r,B,s)  <->  a:A & b:B"
    1.47 +apply (unfold radd_def)
    1.48 +apply blast
    1.49 +done
    1.50 +
    1.51 +lemma radd_Inl_iff [iff]: 
    1.52 +    "<Inl(a'), Inl(a)> : radd(A,r,B,s)  <->  a':A & a:A & <a',a>:r"
    1.53 +apply (unfold radd_def)
    1.54 +apply blast
    1.55 +done
    1.56 +
    1.57 +lemma radd_Inr_iff [iff]: 
    1.58 +    "<Inr(b'), Inr(b)> : radd(A,r,B,s) <->  b':B & b:B & <b',b>:s"
    1.59 +apply (unfold radd_def)
    1.60 +apply blast
    1.61 +done
    1.62 +
    1.63 +lemma radd_Inr_Inl_iff [iff]: 
    1.64 +    "<Inr(b), Inl(a)> : radd(A,r,B,s) <->  False"
    1.65 +apply (unfold radd_def)
    1.66 +apply blast
    1.67 +done
    1.68 +
    1.69 +(** Elimination Rule **)
    1.70 +
    1.71 +lemma raddE:
    1.72 +    "[| <p',p> : radd(A,r,B,s);                  
    1.73 +        !!x y. [| p'=Inl(x); x:A; p=Inr(y); y:B |] ==> Q;        
    1.74 +        !!x' x. [| p'=Inl(x'); p=Inl(x); <x',x>: r; x':A; x:A |] ==> Q;  
    1.75 +        !!y' y. [| p'=Inr(y'); p=Inr(y); <y',y>: s; y':B; y:B |] ==> Q   
    1.76 +     |] ==> Q"
    1.77 +apply (unfold radd_def)
    1.78 +apply (blast intro: elim:); 
    1.79 +done
    1.80 +
    1.81 +(** Type checking **)
    1.82 +
    1.83 +lemma radd_type: "radd(A,r,B,s) <= (A+B) * (A+B)"
    1.84 +apply (unfold radd_def)
    1.85 +apply (rule Collect_subset)
    1.86 +done
    1.87 +
    1.88 +lemmas field_radd = radd_type [THEN field_rel_subset]
    1.89 +
    1.90 +(** Linearity **)
    1.91 +
    1.92 +lemma linear_radd: 
    1.93 +    "[| linear(A,r);  linear(B,s) |] ==> linear(A+B,radd(A,r,B,s))"
    1.94 +apply (unfold linear_def)
    1.95 +apply (blast intro: elim:); 
    1.96 +done
    1.97 +
    1.98 +
    1.99 +(** Well-foundedness **)
   1.100 +
   1.101 +lemma wf_on_radd: "[| wf[A](r);  wf[B](s) |] ==> wf[A+B](radd(A,r,B,s))"
   1.102 +apply (rule wf_onI2)
   1.103 +apply (subgoal_tac "ALL x:A. Inl (x) : Ba")
   1.104 +(*Proving the lemma, which is needed twice!*)
   1.105 + prefer 2
   1.106 + apply (erule_tac V = "y : A + B" in thin_rl)
   1.107 + apply (rule_tac ballI)
   1.108 + apply (erule_tac r = "r" and a = "x" in wf_on_induct, assumption)
   1.109 + apply (blast intro: elim:); 
   1.110 +(*Returning to main part of proof*)
   1.111 +apply safe
   1.112 +apply blast
   1.113 +apply (erule_tac r = "s" and a = "ya" in wf_on_induct , assumption)
   1.114 +apply (blast intro: elim:); 
   1.115 +done
   1.116 +
   1.117 +lemma wf_radd: "[| wf(r);  wf(s) |] ==> wf(radd(field(r),r,field(s),s))"
   1.118 +apply (simp add: wf_iff_wf_on_field)
   1.119 +apply (rule wf_on_subset_A [OF _ field_radd])
   1.120 +apply (blast intro: wf_on_radd) 
   1.121 +done
   1.122 +
   1.123 +lemma well_ord_radd:
   1.124 +     "[| well_ord(A,r);  well_ord(B,s) |] ==> well_ord(A+B, radd(A,r,B,s))"
   1.125 +apply (rule well_ordI)
   1.126 +apply (simp add: well_ord_def wf_on_radd)
   1.127 +apply (simp add: well_ord_def tot_ord_def linear_radd)
   1.128 +done
   1.129 +
   1.130 +(** An ord_iso congruence law **)
   1.131  
   1.132 -constdefs
   1.133 -   measure :: "[i, i\\<Rightarrow>i] \\<Rightarrow> i"
   1.134 -   "measure(A,f) == {<x,y>: A*A. f(x) < f(y)}"
   1.135 +lemma sum_bij:
   1.136 +     "[| f: bij(A,C);  g: bij(B,D) |]
   1.137 +      ==> (lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) : bij(A+B, C+D)"
   1.138 +apply (rule_tac d = "case (%x. Inl (converse (f) `x) , %y. Inr (converse (g) `y))" in lam_bijective)
   1.139 +apply (typecheck add: bij_is_inj inj_is_fun) 
   1.140 +apply (auto simp add: left_inverse_bij right_inverse_bij) 
   1.141 +done
   1.142 +
   1.143 +lemma sum_ord_iso_cong: 
   1.144 +    "[| f: ord_iso(A,r,A',r');  g: ord_iso(B,s,B',s') |] ==>      
   1.145 +            (lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z))             
   1.146 +            : ord_iso(A+B, radd(A,r,B,s), A'+B', radd(A',r',B',s'))"
   1.147 +apply (unfold ord_iso_def)
   1.148 +apply (safe intro!: sum_bij)
   1.149 +(*Do the beta-reductions now*)
   1.150 +apply (auto cong add: conj_cong simp add: bij_is_fun [THEN apply_type])
   1.151 +done
   1.152 +
   1.153 +(*Could we prove an ord_iso result?  Perhaps 
   1.154 +     ord_iso(A+B, radd(A,r,B,s), A Un B, r Un s) *)
   1.155 +lemma sum_disjoint_bij: "A Int B = 0 ==>      
   1.156 +            (lam z:A+B. case(%x. x, %y. y, z)) : bij(A+B, A Un B)"
   1.157 +apply (rule_tac d = "%z. if z:A then Inl (z) else Inr (z) " in lam_bijective)
   1.158 +apply auto
   1.159 +done
   1.160 +
   1.161 +(** Associativity **)
   1.162 +
   1.163 +lemma sum_assoc_bij:
   1.164 +     "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z))  
   1.165 +      : bij((A+B)+C, A+(B+C))"
   1.166 +apply (rule_tac d = "case (%x. Inl (Inl (x)), case (%x. Inl (Inr (x)), Inr))" 
   1.167 +       in lam_bijective)
   1.168 +apply auto
   1.169 +done
   1.170 +
   1.171 +lemma sum_assoc_ord_iso:
   1.172 +     "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z))  
   1.173 +      : ord_iso((A+B)+C, radd(A+B, radd(A,r,B,s), C, t),     
   1.174 +                A+(B+C), radd(A, r, B+C, radd(B,s,C,t)))"
   1.175 +apply (rule sum_assoc_bij [THEN ord_isoI])
   1.176 +apply auto
   1.177 +done
   1.178 +
   1.179 +
   1.180 +(**** Multiplication of relations -- lexicographic product ****)
   1.181 +
   1.182 +(** Rewrite rule.  Can be used to obtain introduction rules **)
   1.183 +
   1.184 +lemma  rmult_iff [iff]: 
   1.185 +    "<<a',b'>, <a,b>> : rmult(A,r,B,s) <->        
   1.186 +            (<a',a>: r  & a':A & a:A & b': B & b: B) |   
   1.187 +            (<b',b>: s  & a'=a & a:A & b': B & b: B)"
   1.188 +
   1.189 +apply (unfold rmult_def)
   1.190 +apply blast
   1.191 +done
   1.192 +
   1.193 +lemma rmultE: 
   1.194 +    "[| <<a',b'>, <a,b>> : rmult(A,r,B,s);               
   1.195 +        [| <a',a>: r;  a':A;  a:A;  b':B;  b:B |] ==> Q;         
   1.196 +        [| <b',b>: s;  a:A;  a'=a;  b':B;  b:B |] ==> Q  
   1.197 +     |] ==> Q"
   1.198 +apply (blast intro: elim:); 
   1.199 +done
   1.200 +
   1.201 +(** Type checking **)
   1.202 +
   1.203 +lemma rmult_type: "rmult(A,r,B,s) <= (A*B) * (A*B)"
   1.204 +apply (unfold rmult_def)
   1.205 +apply (rule Collect_subset)
   1.206 +done
   1.207 +
   1.208 +lemmas field_rmult = rmult_type [THEN field_rel_subset]
   1.209 +
   1.210 +(** Linearity **)
   1.211 +
   1.212 +lemma linear_rmult:
   1.213 +    "[| linear(A,r);  linear(B,s) |] ==> linear(A*B,rmult(A,r,B,s))"
   1.214 +apply (simp add: linear_def); 
   1.215 +apply (blast intro: elim:); 
   1.216 +done
   1.217 +
   1.218 +(** Well-foundedness **)
   1.219 +
   1.220 +lemma wf_on_rmult: "[| wf[A](r);  wf[B](s) |] ==> wf[A*B](rmult(A,r,B,s))"
   1.221 +apply (rule wf_onI2)
   1.222 +apply (erule SigmaE)
   1.223 +apply (erule ssubst)
   1.224 +apply (subgoal_tac "ALL b:B. <x,b>: Ba")
   1.225 +apply blast
   1.226 +apply (erule_tac a = "x" in wf_on_induct , assumption)
   1.227 +apply (rule ballI)
   1.228 +apply (erule_tac a = "b" in wf_on_induct , assumption)
   1.229 +apply (best elim!: rmultE bspec [THEN mp])
   1.230 +done
   1.231 +
   1.232 +
   1.233 +lemma wf_rmult: "[| wf(r);  wf(s) |] ==> wf(rmult(field(r),r,field(s),s))"
   1.234 +apply (simp add: wf_iff_wf_on_field)
   1.235 +apply (rule wf_on_subset_A [OF _ field_rmult])
   1.236 +apply (blast intro: wf_on_rmult) 
   1.237 +done
   1.238 +
   1.239 +lemma well_ord_rmult:
   1.240 +     "[| well_ord(A,r);  well_ord(B,s) |] ==> well_ord(A*B, rmult(A,r,B,s))"
   1.241 +apply (rule well_ordI)
   1.242 +apply (simp add: well_ord_def wf_on_rmult)
   1.243 +apply (simp add: well_ord_def tot_ord_def linear_rmult)
   1.244 +done
   1.245  
   1.246  
   1.247 +(** An ord_iso congruence law **)
   1.248 +
   1.249 +lemma prod_bij:
   1.250 +     "[| f: bij(A,C);  g: bij(B,D) |] 
   1.251 +      ==> (lam <x,y>:A*B. <f`x, g`y>) : bij(A*B, C*D)"
   1.252 +apply (rule_tac d = "%<x,y>. <converse (f) `x, converse (g) `y>" 
   1.253 +       in lam_bijective)
   1.254 +apply (typecheck add: bij_is_inj inj_is_fun) 
   1.255 +apply (auto simp add: left_inverse_bij right_inverse_bij) 
   1.256 +done
   1.257 +
   1.258 +lemma prod_ord_iso_cong: 
   1.259 +    "[| f: ord_iso(A,r,A',r');  g: ord_iso(B,s,B',s') |]      
   1.260 +     ==> (lam <x,y>:A*B. <f`x, g`y>)                                  
   1.261 +         : ord_iso(A*B, rmult(A,r,B,s), A'*B', rmult(A',r',B',s'))"
   1.262 +apply (unfold ord_iso_def)
   1.263 +apply (safe intro!: prod_bij)
   1.264 +apply (simp_all add: bij_is_fun [THEN apply_type])
   1.265 +apply (blast intro: bij_is_inj [THEN inj_apply_equality])
   1.266 +done
   1.267 +
   1.268 +lemma singleton_prod_bij: "(lam z:A. <x,z>) : bij(A, {x}*A)"
   1.269 +apply (rule_tac d = "snd" in lam_bijective)
   1.270 +apply auto
   1.271 +done
   1.272 +
   1.273 +(*Used??*)
   1.274 +lemma singleton_prod_ord_iso:
   1.275 +     "well_ord({x},xr) ==>   
   1.276 +          (lam z:A. <x,z>) : ord_iso(A, r, {x}*A, rmult({x}, xr, A, r))"
   1.277 +apply (rule singleton_prod_bij [THEN ord_isoI])
   1.278 +apply (simp (no_asm_simp))
   1.279 +apply (blast dest: well_ord_is_wf [THEN wf_on_not_refl])
   1.280 +done
   1.281 +
   1.282 +(*Here we build a complicated function term, then simplify it using
   1.283 +  case_cong, id_conv, comp_lam, case_case.*)
   1.284 +lemma prod_sum_singleton_bij:
   1.285 +     "a~:C ==>  
   1.286 +       (lam x:C*B + D. case(%x. x, %y.<a,y>, x))  
   1.287 +       : bij(C*B + D, C*B Un {a}*D)"
   1.288 +apply (rule subst_elem)
   1.289 +apply (rule id_bij [THEN sum_bij, THEN comp_bij])
   1.290 +apply (rule singleton_prod_bij)
   1.291 +apply (rule sum_disjoint_bij)
   1.292 +apply blast
   1.293 +apply (simp (no_asm_simp) cong add: case_cong)
   1.294 +apply (rule comp_lam [THEN trans, symmetric])
   1.295 +apply (fast elim!: case_type)
   1.296 +apply (simp (no_asm_simp) add: case_case)
   1.297 +done
   1.298 +
   1.299 +lemma prod_sum_singleton_ord_iso:
   1.300 + "[| a:A;  well_ord(A,r) |] ==>  
   1.301 +    (lam x:pred(A,a,r)*B + pred(B,b,s). case(%x. x, %y.<a,y>, x))  
   1.302 +    : ord_iso(pred(A,a,r)*B + pred(B,b,s),               
   1.303 +                  radd(A*B, rmult(A,r,B,s), B, s),       
   1.304 +              pred(A,a,r)*B Un {a}*pred(B,b,s), rmult(A,r,B,s))"
   1.305 +apply (rule prod_sum_singleton_bij [THEN ord_isoI])
   1.306 +apply (simp (no_asm_simp) add: pred_iff well_ord_is_wf [THEN wf_on_not_refl])
   1.307 +apply (auto elim!: well_ord_is_wf [THEN wf_on_asym] predE)
   1.308 +done
   1.309 +
   1.310 +(** Distributive law **)
   1.311 +
   1.312 +lemma sum_prod_distrib_bij:
   1.313 +     "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x))  
   1.314 +      : bij((A+B)*C, (A*C)+(B*C))"
   1.315 +apply (rule_tac d = "case (%<x,y>.<Inl (x) ,y>, %<x,y>.<Inr (x) ,y>) " 
   1.316 +       in lam_bijective)
   1.317 +apply auto
   1.318 +done
   1.319 +
   1.320 +lemma sum_prod_distrib_ord_iso:
   1.321 + "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x))  
   1.322 +  : ord_iso((A+B)*C, rmult(A+B, radd(A,r,B,s), C, t),  
   1.323 +            (A*C)+(B*C), radd(A*C, rmult(A,r,C,t), B*C, rmult(B,s,C,t)))"
   1.324 +apply (rule sum_prod_distrib_bij [THEN ord_isoI])
   1.325 +apply auto
   1.326 +done
   1.327 +
   1.328 +(** Associativity **)
   1.329 +
   1.330 +lemma prod_assoc_bij:
   1.331 +     "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) : bij((A*B)*C, A*(B*C))"
   1.332 +apply (rule_tac d = "%<x, <y,z>>. <<x,y>, z>" in lam_bijective)
   1.333 +apply auto
   1.334 +done
   1.335 +
   1.336 +lemma prod_assoc_ord_iso:
   1.337 + "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>)                    
   1.338 +  : ord_iso((A*B)*C, rmult(A*B, rmult(A,r,B,s), C, t),   
   1.339 +            A*(B*C), rmult(A, r, B*C, rmult(B,s,C,t)))"
   1.340 +apply (rule prod_assoc_bij [THEN ord_isoI])
   1.341 +apply auto
   1.342 +done
   1.343 +
   1.344 +(**** Inverse image of a relation ****)
   1.345 +
   1.346 +(** Rewrite rule **)
   1.347 +
   1.348 +lemma rvimage_iff: "<a,b> : rvimage(A,f,r)  <->  <f`a,f`b>: r & a:A & b:A"
   1.349 +apply (unfold rvimage_def)
   1.350 +apply blast
   1.351 +done
   1.352 +
   1.353 +(** Type checking **)
   1.354 +
   1.355 +lemma rvimage_type: "rvimage(A,f,r) <= A*A"
   1.356 +apply (unfold rvimage_def)
   1.357 +apply (rule Collect_subset)
   1.358 +done
   1.359 +
   1.360 +lemmas field_rvimage = rvimage_type [THEN field_rel_subset]
   1.361 +
   1.362 +lemma rvimage_converse: "rvimage(A,f, converse(r)) = converse(rvimage(A,f,r))"
   1.363 +apply (unfold rvimage_def)
   1.364 +apply blast
   1.365 +done
   1.366 +
   1.367 +
   1.368 +(** Partial Ordering Properties **)
   1.369 +
   1.370 +lemma irrefl_rvimage: 
   1.371 +    "[| f: inj(A,B);  irrefl(B,r) |] ==> irrefl(A, rvimage(A,f,r))"
   1.372 +apply (unfold irrefl_def rvimage_def)
   1.373 +apply (blast intro: inj_is_fun [THEN apply_type])
   1.374 +done
   1.375 +
   1.376 +lemma trans_on_rvimage: 
   1.377 +    "[| f: inj(A,B);  trans[B](r) |] ==> trans[A](rvimage(A,f,r))"
   1.378 +apply (unfold trans_on_def rvimage_def)
   1.379 +apply (blast intro: inj_is_fun [THEN apply_type])
   1.380 +done
   1.381 +
   1.382 +lemma part_ord_rvimage: 
   1.383 +    "[| f: inj(A,B);  part_ord(B,r) |] ==> part_ord(A, rvimage(A,f,r))"
   1.384 +apply (unfold part_ord_def)
   1.385 +apply (blast intro!: irrefl_rvimage trans_on_rvimage)
   1.386 +done
   1.387 +
   1.388 +(** Linearity **)
   1.389 +
   1.390 +lemma linear_rvimage:
   1.391 +    "[| f: inj(A,B);  linear(B,r) |] ==> linear(A,rvimage(A,f,r))"
   1.392 +apply (simp add: inj_def linear_def rvimage_iff) 
   1.393 +apply (blast intro: apply_funtype); 
   1.394 +done
   1.395 +
   1.396 +lemma tot_ord_rvimage: 
   1.397 +    "[| f: inj(A,B);  tot_ord(B,r) |] ==> tot_ord(A, rvimage(A,f,r))"
   1.398 +apply (unfold tot_ord_def)
   1.399 +apply (blast intro!: part_ord_rvimage linear_rvimage)
   1.400 +done
   1.401 +
   1.402 +
   1.403 +(** Well-foundedness **)
   1.404 +
   1.405 +(*Not sure if wf_on_rvimage could be proved from this!*)
   1.406 +lemma wf_rvimage [intro!]: "wf(r) ==> wf(rvimage(A,f,r))"
   1.407 +apply (simp (no_asm_use) add: rvimage_def wf_eq_minimal)
   1.408 +apply clarify
   1.409 +apply (subgoal_tac "EX w. w : {w: {f`x. x:Q}. EX x. x: Q & (f`x = w) }")
   1.410 + apply (erule allE)
   1.411 + apply (erule impE)
   1.412 + apply assumption; 
   1.413 + apply blast
   1.414 +apply (blast intro: elim:); 
   1.415 +done
   1.416 +
   1.417 +lemma wf_on_rvimage: "[| f: A->B;  wf[B](r) |] ==> wf[A](rvimage(A,f,r))"
   1.418 +apply (rule wf_onI2)
   1.419 +apply (subgoal_tac "ALL z:A. f`z=f`y --> z: Ba")
   1.420 + apply blast
   1.421 +apply (erule_tac a = "f`y" in wf_on_induct)
   1.422 + apply (blast intro!: apply_funtype)
   1.423 +apply (blast intro!: apply_funtype dest!: rvimage_iff [THEN iffD1])
   1.424 +done
   1.425 +
   1.426 +(*Note that we need only wf[A](...) and linear(A,...) to get the result!*)
   1.427 +lemma well_ord_rvimage:
   1.428 +     "[| f: inj(A,B);  well_ord(B,r) |] ==> well_ord(A, rvimage(A,f,r))"
   1.429 +apply (rule well_ordI)
   1.430 +apply (unfold well_ord_def tot_ord_def)
   1.431 +apply (blast intro!: wf_on_rvimage inj_is_fun)
   1.432 +apply (blast intro!: linear_rvimage)
   1.433 +done
   1.434 +
   1.435 +lemma ord_iso_rvimage: 
   1.436 +    "f: bij(A,B) ==> f: ord_iso(A, rvimage(A,f,s), B, s)"
   1.437 +apply (unfold ord_iso_def)
   1.438 +apply (simp add: rvimage_iff)
   1.439 +done
   1.440 +
   1.441 +lemma ord_iso_rvimage_eq: 
   1.442 +    "f: ord_iso(A,r, B,s) ==> rvimage(A,f,s) = r Int A*A"
   1.443 +apply (unfold ord_iso_def rvimage_def)
   1.444 +apply blast
   1.445 +done
   1.446 +
   1.447 +
   1.448 +(** The "measure" relation is useful with wfrec **)
   1.449 +
   1.450 +lemma measure_eq_rvimage_Memrel:
   1.451 +     "measure(A,f) = rvimage(A,Lambda(A,f),Memrel(Collect(RepFun(A,f),Ord)))"
   1.452 +apply (simp (no_asm) add: measure_def rvimage_def Memrel_iff)
   1.453 +apply (rule equalityI)
   1.454 +apply auto
   1.455 +apply (auto intro: Ord_in_Ord simp add: lt_def)
   1.456 +done
   1.457 +
   1.458 +lemma wf_measure [iff]: "wf(measure(A,f))"
   1.459 +apply (simp (no_asm) add: measure_eq_rvimage_Memrel wf_Memrel wf_rvimage)
   1.460 +done
   1.461 +
   1.462 +lemma measure_iff [iff]: "<x,y> : measure(A,f) <-> x:A & y:A & f(x)<f(y)"
   1.463 +apply (simp (no_asm) add: measure_def)
   1.464 +done
   1.465 +
   1.466 +ML {*
   1.467 +val measure_def = thm "measure_def";
   1.468 +val radd_Inl_Inr_iff = thm "radd_Inl_Inr_iff";
   1.469 +val radd_Inl_iff = thm "radd_Inl_iff";
   1.470 +val radd_Inr_iff = thm "radd_Inr_iff";
   1.471 +val radd_Inr_Inl_iff = thm "radd_Inr_Inl_iff";
   1.472 +val raddE = thm "raddE";
   1.473 +val radd_type = thm "radd_type";
   1.474 +val field_radd = thm "field_radd";
   1.475 +val linear_radd = thm "linear_radd";
   1.476 +val wf_on_radd = thm "wf_on_radd";
   1.477 +val wf_radd = thm "wf_radd";
   1.478 +val well_ord_radd = thm "well_ord_radd";
   1.479 +val sum_bij = thm "sum_bij";
   1.480 +val sum_ord_iso_cong = thm "sum_ord_iso_cong";
   1.481 +val sum_disjoint_bij = thm "sum_disjoint_bij";
   1.482 +val sum_assoc_bij = thm "sum_assoc_bij";
   1.483 +val sum_assoc_ord_iso = thm "sum_assoc_ord_iso";
   1.484 +val rmult_iff = thm "rmult_iff";
   1.485 +val rmultE = thm "rmultE";
   1.486 +val rmult_type = thm "rmult_type";
   1.487 +val field_rmult = thm "field_rmult";
   1.488 +val linear_rmult = thm "linear_rmult";
   1.489 +val wf_on_rmult = thm "wf_on_rmult";
   1.490 +val wf_rmult = thm "wf_rmult";
   1.491 +val well_ord_rmult = thm "well_ord_rmult";
   1.492 +val prod_bij = thm "prod_bij";
   1.493 +val prod_ord_iso_cong = thm "prod_ord_iso_cong";
   1.494 +val singleton_prod_bij = thm "singleton_prod_bij";
   1.495 +val singleton_prod_ord_iso = thm "singleton_prod_ord_iso";
   1.496 +val prod_sum_singleton_bij = thm "prod_sum_singleton_bij";
   1.497 +val prod_sum_singleton_ord_iso = thm "prod_sum_singleton_ord_iso";
   1.498 +val sum_prod_distrib_bij = thm "sum_prod_distrib_bij";
   1.499 +val sum_prod_distrib_ord_iso = thm "sum_prod_distrib_ord_iso";
   1.500 +val prod_assoc_bij = thm "prod_assoc_bij";
   1.501 +val prod_assoc_ord_iso = thm "prod_assoc_ord_iso";
   1.502 +val rvimage_iff = thm "rvimage_iff";
   1.503 +val rvimage_type = thm "rvimage_type";
   1.504 +val field_rvimage = thm "field_rvimage";
   1.505 +val rvimage_converse = thm "rvimage_converse";
   1.506 +val irrefl_rvimage = thm "irrefl_rvimage";
   1.507 +val trans_on_rvimage = thm "trans_on_rvimage";
   1.508 +val part_ord_rvimage = thm "part_ord_rvimage";
   1.509 +val linear_rvimage = thm "linear_rvimage";
   1.510 +val tot_ord_rvimage = thm "tot_ord_rvimage";
   1.511 +val wf_rvimage = thm "wf_rvimage";
   1.512 +val wf_on_rvimage = thm "wf_on_rvimage";
   1.513 +val well_ord_rvimage = thm "well_ord_rvimage";
   1.514 +val ord_iso_rvimage = thm "ord_iso_rvimage";
   1.515 +val ord_iso_rvimage_eq = thm "ord_iso_rvimage_eq";
   1.516 +val measure_eq_rvimage_Memrel = thm "measure_eq_rvimage_Memrel";
   1.517 +val wf_measure = thm "wf_measure";
   1.518 +val measure_iff = thm "measure_iff";
   1.519 +*}
   1.520 +
   1.521  end