src/ZF/OrderArith.ML
changeset 8201 a81d18b0a9b1
parent 6068 2d8f3e1f1151
child 9173 422968aeed49
equal deleted inserted replaced
8200:700067a98634 8201:a81d18b0a9b1
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1994  University of Cambridge
     4     Copyright   1994  University of Cambridge
     5 
     5 
     6 Towards ordinal arithmetic 
     6 Towards ordinal arithmetic 
     7 *)
     7 *)
     8 
       
     9 open OrderArith;
       
    10 
       
    11 
     8 
    12 (**** Addition of relations -- disjoint sum ****)
     9 (**** Addition of relations -- disjoint sum ****)
    13 
    10 
    14 (** Rewrite rules.  Can be used to obtain introduction rules **)
    11 (** Rewrite rules.  Can be used to obtain introduction rules **)
    15 
    12 
    65 Addsimps [radd_Inl_iff, radd_Inr_iff, 
    62 Addsimps [radd_Inl_iff, radd_Inr_iff, 
    66           radd_Inl_Inr_iff, radd_Inr_Inl_iff];
    63           radd_Inl_Inr_iff, radd_Inr_Inl_iff];
    67 
    64 
    68 Goalw [linear_def]
    65 Goalw [linear_def]
    69     "[| linear(A,r);  linear(B,s) |] ==> linear(A+B,radd(A,r,B,s))";
    66     "[| linear(A,r);  linear(B,s) |] ==> linear(A+B,radd(A,r,B,s))";
    70 by (REPEAT_FIRST (ares_tac [ballI] ORELSE' etac sumE));
    67 by (Force_tac 1);
    71 by (ALLGOALS Asm_simp_tac);
       
    72 qed "linear_radd";
    68 qed "linear_radd";
    73 
    69 
    74 
    70 
    75 (** Well-foundedness **)
    71 (** Well-foundedness **)
    76 
    72 
   108 Goal "[| f: bij(A,C);  g: bij(B,D) |] ==> \
   104 Goal "[| f: bij(A,C);  g: bij(B,D) |] ==> \
   109 \        (lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) : bij(A+B, C+D)";
   105 \        (lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) : bij(A+B, C+D)";
   110 by (res_inst_tac 
   106 by (res_inst_tac 
   111         [("d", "case(%x. Inl(converse(f)`x), %y. Inr(converse(g)`y))")] 
   107         [("d", "case(%x. Inl(converse(f)`x), %y. Inr(converse(g)`y))")] 
   112     lam_bijective 1);
   108     lam_bijective 1);
   113 by (safe_tac (claset() addSEs [sumE]));
   109 by Safe_tac;
   114 by (ALLGOALS (asm_simp_tac bij_inverse_ss));
   110 by (ALLGOALS (asm_simp_tac bij_inverse_ss));
   115 qed "sum_bij";
   111 qed "sum_bij";
   116 
   112 
   117 Goalw [ord_iso_def]
   113 Goalw [ord_iso_def]
   118     "[| f: ord_iso(A,r,A',r');  g: ord_iso(B,s,B',s') |] ==>     \
   114     "[| f: ord_iso(A,r,A',r');  g: ord_iso(B,s,B',s') |] ==>     \
   132      ord_iso(A+B, radd(A,r,B,s), A Un B, r Un s) *)
   128      ord_iso(A+B, radd(A,r,B,s), A Un B, r Un s) *)
   133 Goal "A Int B = 0 ==>     \
   129 Goal "A Int B = 0 ==>     \
   134 \           (lam z:A+B. case(%x. x, %y. y, z)) : bij(A+B, A Un B)";
   130 \           (lam z:A+B. case(%x. x, %y. y, z)) : bij(A+B, A Un B)";
   135 by (res_inst_tac [("d", "%z. if z:A then Inl(z) else Inr(z)")] 
   131 by (res_inst_tac [("d", "%z. if z:A then Inl(z) else Inr(z)")] 
   136     lam_bijective 1);
   132     lam_bijective 1);
   137 by (blast_tac (claset() addSIs [if_type]) 2);
   133 by Auto_tac;
   138 by (DEPTH_SOLVE_1 (eresolve_tac [case_type, UnI1, UnI2] 1));
       
   139 by Safe_tac;
       
   140 by (ALLGOALS Asm_simp_tac);
       
   141 by (blast_tac (claset() addEs [equalityE]) 1);
       
   142 qed "sum_disjoint_bij";
   134 qed "sum_disjoint_bij";
   143 
   135 
   144 (** Associativity **)
   136 (** Associativity **)
   145 
   137 
   146 Goal "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) \
   138 Goal "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) \
   147 \ : bij((A+B)+C, A+(B+C))";
   139 \ : bij((A+B)+C, A+(B+C))";
   148 by (res_inst_tac [("d", "case(%x. Inl(Inl(x)), case(%x. Inl(Inr(x)), Inr))")] 
   140 by (res_inst_tac [("d", "case(%x. Inl(Inl(x)), case(%x. Inl(Inr(x)), Inr))")] 
   149     lam_bijective 1);
   141     lam_bijective 1);
   150 by (ALLGOALS (asm_simp_tac (simpset() setloop etac sumE)));
   142 by Auto_tac;
   151 qed "sum_assoc_bij";
   143 qed "sum_assoc_bij";
   152 
   144 
   153 Goal "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) \
   145 Goal "(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) \
   154 \ : ord_iso((A+B)+C, radd(A+B, radd(A,r,B,s), C, t),    \
   146 \ : ord_iso((A+B)+C, radd(A+B, radd(A,r,B,s), C, t),    \
   155 \           A+(B+C), radd(A, r, B+C, radd(B,s,C,t)))";
   147 \           A+(B+C), radd(A, r, B+C, radd(B,s,C,t)))";
   156 by (resolve_tac [sum_assoc_bij RS ord_isoI] 1);
   148 by (resolve_tac [sum_assoc_bij RS ord_isoI] 1);
   157 by (REPEAT_FIRST (etac sumE));
   149 by Auto_tac;
   158 by (ALLGOALS Asm_simp_tac);
       
   159 qed "sum_assoc_ord_iso";
   150 qed "sum_assoc_ord_iso";
   160 
   151 
   161 
   152 
   162 (**** Multiplication of relations -- lexicographic product ****)
   153 (**** Multiplication of relations -- lexicographic product ****)
   163 
   154 
   253 by (blast_tac (claset() addIs [bij_is_inj RS inj_apply_equality]) 1);
   244 by (blast_tac (claset() addIs [bij_is_inj RS inj_apply_equality]) 1);
   254 qed "prod_ord_iso_cong";
   245 qed "prod_ord_iso_cong";
   255 
   246 
   256 Goal "(lam z:A. <x,z>) : bij(A, {x}*A)";
   247 Goal "(lam z:A. <x,z>) : bij(A, {x}*A)";
   257 by (res_inst_tac [("d", "snd")] lam_bijective 1);
   248 by (res_inst_tac [("d", "snd")] lam_bijective 1);
   258 by Safe_tac;
   249 by Auto_tac;
   259 by (ALLGOALS Asm_simp_tac);
       
   260 qed "singleton_prod_bij";
   250 qed "singleton_prod_bij";
   261 
   251 
   262 (*Used??*)
   252 (*Used??*)
   263 Goal "well_ord({x},xr) ==>  \
   253 Goal "well_ord({x},xr) ==>  \
   264 \         (lam z:A. <x,z>) : ord_iso(A, r, {x}*A, rmult({x}, xr, A, r))";
   254 \         (lam z:A. <x,z>) : ord_iso(A, r, {x}*A, rmult({x}, xr, A, r))";
   275 by (rtac subst_elem 1);
   265 by (rtac subst_elem 1);
   276 by (resolve_tac [id_bij RS sum_bij RS comp_bij] 1);
   266 by (resolve_tac [id_bij RS sum_bij RS comp_bij] 1);
   277 by (rtac singleton_prod_bij 1);
   267 by (rtac singleton_prod_bij 1);
   278 by (rtac sum_disjoint_bij 1);
   268 by (rtac sum_disjoint_bij 1);
   279 by (Blast_tac 1);
   269 by (Blast_tac 1);
   280 by (asm_simp_tac (simpset() addcongs [case_cong] addsimps [id_conv]) 1);
   270 by (asm_simp_tac (simpset() addcongs [case_cong]) 1);
   281 by (resolve_tac [comp_lam RS trans RS sym] 1);
   271 by (resolve_tac [comp_lam RS trans RS sym] 1);
   282 by (fast_tac (claset() addSEs [case_type]) 1);
   272 by (fast_tac (claset() addSEs [case_type]) 1);
   283 by (asm_simp_tac (simpset() addsimps [case_case]) 1);
   273 by (asm_simp_tac (simpset() addsimps [case_case]) 1);
   284 qed "prod_sum_singleton_bij";
   274 qed "prod_sum_singleton_bij";
   285 
   275 
   301 
   291 
   302 Goal "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) \
   292 Goal "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) \
   303 \ : bij((A+B)*C, (A*C)+(B*C))";
   293 \ : bij((A+B)*C, (A*C)+(B*C))";
   304 by (res_inst_tac
   294 by (res_inst_tac
   305     [("d", "case(%<x,y>.<Inl(x),y>, %<x,y>.<Inr(x),y>)")] lam_bijective 1);
   295     [("d", "case(%<x,y>.<Inl(x),y>, %<x,y>.<Inr(x),y>)")] lam_bijective 1);
   306 by (safe_tac (claset() addSEs [sumE]));
   296 by Auto_tac;
   307 by (ALLGOALS Asm_simp_tac);
       
   308 qed "sum_prod_distrib_bij";
   297 qed "sum_prod_distrib_bij";
   309 
   298 
   310 Goal "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) \
   299 Goal "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) \
   311 \ : ord_iso((A+B)*C, rmult(A+B, radd(A,r,B,s), C, t), \
   300 \ : ord_iso((A+B)*C, rmult(A+B, radd(A,r,B,s), C, t), \
   312 \           (A*C)+(B*C), radd(A*C, rmult(A,r,C,t), B*C, rmult(B,s,C,t)))";
   301 \           (A*C)+(B*C), radd(A*C, rmult(A,r,C,t), B*C, rmult(B,s,C,t)))";
   313 by (resolve_tac [sum_prod_distrib_bij RS ord_isoI] 1);
   302 by (resolve_tac [sum_prod_distrib_bij RS ord_isoI] 1);
   314 by (REPEAT_FIRST (eresolve_tac [SigmaE, sumE]));
   303 by Auto_tac;
   315 by (ALLGOALS Asm_simp_tac);
       
   316 qed "sum_prod_distrib_ord_iso";
   304 qed "sum_prod_distrib_ord_iso";
   317 
   305 
   318 (** Associativity **)
   306 (** Associativity **)
   319 
   307 
   320 Goal "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) : bij((A*B)*C, A*(B*C))";
   308 Goal "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) : bij((A*B)*C, A*(B*C))";
   321 by (res_inst_tac [("d", "%<x, <y,z>>. <<x,y>, z>")] lam_bijective 1);
   309 by (res_inst_tac [("d", "%<x, <y,z>>. <<x,y>, z>")] lam_bijective 1);
   322 by (ALLGOALS (asm_simp_tac (simpset() setloop etac SigmaE)));
   310 by Auto_tac;
   323 qed "prod_assoc_bij";
   311 qed "prod_assoc_bij";
   324 
   312 
   325 Goal "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>)                   \
   313 Goal "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>)                   \
   326 \ : ord_iso((A*B)*C, rmult(A*B, rmult(A,r,B,s), C, t),  \
   314 \ : ord_iso((A*B)*C, rmult(A*B, rmult(A,r,B,s), C, t),  \
   327 \           A*(B*C), rmult(A, r, B*C, rmult(B,s,C,t)))";
   315 \           A*(B*C), rmult(A, r, B*C, rmult(B,s,C,t)))";
   328 by (resolve_tac [prod_assoc_bij RS ord_isoI] 1);
   316 by (resolve_tac [prod_assoc_bij RS ord_isoI] 1);
   329 by (REPEAT_FIRST (eresolve_tac [SigmaE, ssubst]));
   317 by Auto_tac;
   330 by (Asm_simp_tac 1);
       
   331 by (Blast_tac 1);
       
   332 qed "prod_assoc_ord_iso";
   318 qed "prod_assoc_ord_iso";
   333 
   319 
   334 (**** Inverse image of a relation ****)
   320 (**** Inverse image of a relation ****)
   335 
   321 
   336 (** Rewrite rule **)
   322 (** Rewrite rule **)
   337 
   323 
   338 Goalw [rvimage_def] 
   324 Goalw [rvimage_def] "<a,b> : rvimage(A,f,r)  <->  <f`a,f`b>: r & a:A & b:A";
   339     "<a,b> : rvimage(A,f,r)  <->  <f`a,f`b>: r & a:A & b:A";
       
   340 by (Blast_tac 1);
   325 by (Blast_tac 1);
   341 qed "rvimage_iff";
   326 qed "rvimage_iff";
   342 
   327 
   343 (** Type checking **)
   328 (** Type checking **)
   344 
   329 
   346 by (rtac Collect_subset 1);
   331 by (rtac Collect_subset 1);
   347 qed "rvimage_type";
   332 qed "rvimage_type";
   348 
   333 
   349 bind_thm ("field_rvimage", (rvimage_type RS field_rel_subset));
   334 bind_thm ("field_rvimage", (rvimage_type RS field_rel_subset));
   350 
   335 
   351 Goalw [rvimage_def] 
   336 Goalw [rvimage_def] "rvimage(A,f, converse(r)) = converse(rvimage(A,f,r))";
   352     "rvimage(A,f, converse(r)) = converse(rvimage(A,f,r))";
       
   353 by (Blast_tac 1);
   337 by (Blast_tac 1);
   354 qed "rvimage_converse";
   338 qed "rvimage_converse";
   355 
   339 
   356 
   340 
   357 (** Partial Ordering Properties **)
   341 (** Partial Ordering Properties **)
   396 by (subgoal_tac "ALL z:A. f`z=f`y --> z: Ba" 1);
   380 by (subgoal_tac "ALL z:A. f`z=f`y --> z: Ba" 1);
   397 by (Blast_tac 1);
   381 by (Blast_tac 1);
   398 by (eres_inst_tac [("a","f`y")] wf_on_induct 1);
   382 by (eres_inst_tac [("a","f`y")] wf_on_induct 1);
   399 by (blast_tac (claset() addSIs [apply_funtype]) 1);
   383 by (blast_tac (claset() addSIs [apply_funtype]) 1);
   400 by (blast_tac (claset() addSIs [apply_funtype] 
   384 by (blast_tac (claset() addSIs [apply_funtype] 
   401                        addSDs [rvimage_iff RS iffD1]) 1);
   385                         addSDs [rvimage_iff RS iffD1]) 1);
   402 qed "wf_on_rvimage";
   386 qed "wf_on_rvimage";
   403 
   387 
   404 (*Note that we need only wf[A](...) and linear(A,...) to get the result!*)
   388 (*Note that we need only wf[A](...) and linear(A,...) to get the result!*)
   405 Goal "[| f: inj(A,B);  well_ord(B,r) |] ==> well_ord(A, rvimage(A,f,r))";
   389 Goal "[| f: inj(A,B);  well_ord(B,r) |] ==> well_ord(A, rvimage(A,f,r))";
   406 by (rtac well_ordI 1);
   390 by (rtac well_ordI 1);