src/HOL/Real/PRat.ML
changeset 10232 529c65b5dcde
parent 9969 4753185f1dd2
child 10752 c4f1bf2acf4c
equal deleted inserted replaced
10231:178a272bceeb 10232:529c65b5dcde
     2     ID          : $Id$
     2     ID          : $Id$
     3     Author      : Jacques D. Fleuriot
     3     Author      : Jacques D. Fleuriot
     4     Copyright   : 1998  University of Cambridge
     4     Copyright   : 1998  University of Cambridge
     5     Description : The positive rationals
     5     Description : The positive rationals
     6 *) 
     6 *) 
     7 
       
     8 Delrules [equalityI];
       
     9 
     7 
    10 (*** Many theorems similar to those in theory Integ ***)
     8 (*** Many theorems similar to those in theory Integ ***)
    11 (*** Proving that ratrel is an equivalence relation ***)
     9 (*** Proving that ratrel is an equivalence relation ***)
    12 
    10 
    13 Goal "[| (x1::pnat) * y2 = x2 * y1; x2 * y3 = x3 * y2 |] \
    11 Goal "[| (x1::pnat) * y2 = x2 * y1; x2 * y3 = x3 * y2 |] \
   107 qed "eq_Abs_prat";
   105 qed "eq_Abs_prat";
   108 
   106 
   109 (**** qinv: inverse on prat ****)
   107 (**** qinv: inverse on prat ****)
   110 
   108 
   111 Goalw [congruent_def] "congruent ratrel (%(x,y). ratrel^^{(y,x)})";
   109 Goalw [congruent_def] "congruent ratrel (%(x,y). ratrel^^{(y,x)})";
   112 by Safe_tac;
   110 by (auto_tac (claset(), simpset() addsimps [pnat_mult_commute]));  
   113 by (asm_full_simp_tac (simpset() addsimps [pnat_mult_commute]) 1);
       
   114 qed "qinv_congruent";
   111 qed "qinv_congruent";
   115 
   112 
   116 Goalw [qinv_def]
   113 Goalw [qinv_def]
   117       "qinv (Abs_prat(ratrel^^{(x,y)})) = Abs_prat(ratrel ^^ {(y,x)})";
   114       "qinv (Abs_prat(ratrel^^{(x,y)})) = Abs_prat(ratrel ^^ {(y,x)})";
   118 by (simp_tac (simpset() addsimps 
   115 by (simp_tac (simpset() addsimps 
   148 qed "prat_add_congruent2_lemma";
   145 qed "prat_add_congruent2_lemma";
   149 
   146 
   150 Goal "congruent2 ratrel (%p1 p2.                  \
   147 Goal "congruent2 ratrel (%p1 p2.                  \
   151 \        (%(x1,y1). (%(x2,y2). ratrel^^{(x1*y2 + x2*y1, y1*y2)}) p2) p1)";
   148 \        (%(x1,y1). (%(x2,y2). ratrel^^{(x1*y2 + x2*y1, y1*y2)}) p2) p1)";
   152 by (rtac (equiv_ratrel RS congruent2_commuteI) 1);
   149 by (rtac (equiv_ratrel RS congruent2_commuteI) 1);
   153 by (auto_tac (claset(),simpset() addsimps [prat_add_congruent2_lemma]));
   150 by (auto_tac (claset() delrules [equalityI],
       
   151               simpset() addsimps [prat_add_congruent2_lemma]));
   154 by (asm_simp_tac (simpset() addsimps [pnat_mult_commute,pnat_add_commute]) 1);
   152 by (asm_simp_tac (simpset() addsimps [pnat_mult_commute,pnat_add_commute]) 1);
   155 qed "prat_add_congruent2";
   153 qed "prat_add_congruent2";
   156 
   154 
   157 Goalw [prat_add_def]
   155 Goalw [prat_add_def]
   158    "Abs_prat((ratrel^^{(x1,y1)})) + Abs_prat((ratrel^^{(x2,y2)})) =   \
   156    "Abs_prat((ratrel^^{(x1,y1)})) + Abs_prat((ratrel^^{(x2,y2)})) =   \
   191 
   189 
   192 Goalw [congruent2_def]
   190 Goalw [congruent2_def]
   193     "congruent2 ratrel (%p1 p2.                  \
   191     "congruent2 ratrel (%p1 p2.                  \
   194 \         (%(x1,y1). (%(x2,y2). ratrel^^{(x1*x2, y1*y2)}) p2) p1)";
   192 \         (%(x1,y1). (%(x2,y2). ratrel^^{(x1*x2, y1*y2)}) p2) p1)";
   195 (*Proof via congruent2_commuteI seems longer*)
   193 (*Proof via congruent2_commuteI seems longer*)
   196 by Safe_tac;
   194 by (Clarify_tac 1);
   197 by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc]) 1);
   195 by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc]) 1);
   198 (*The rest should be trivial, but rearranging terms is hard*)
   196 (*The rest should be trivial, but rearranging terms is hard*)
   199 by (res_inst_tac [("x1","x1a")] (pnat_mult_left_commute RS ssubst) 1);
   197 by (res_inst_tac [("x1","x1a")] (pnat_mult_left_commute RS ssubst) 1);
   200 by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc RS sym]) 1);
   198 by (asm_simp_tac (simpset() addsimps [pnat_mult_assoc RS sym]) 1);
   201 by (asm_simp_tac (simpset() addsimps pnat_mult_ac) 1);
   199 by (asm_simp_tac (simpset() addsimps pnat_mult_ac) 1);
   383 by (dtac prat_less_trans 1 THEN assume_tac 1);
   381 by (dtac prat_less_trans 1 THEN assume_tac 1);
   384 by (asm_full_simp_tac (simpset() addsimps [prat_less_not_refl]) 1);
   382 by (asm_full_simp_tac (simpset() addsimps [prat_less_not_refl]) 1);
   385 qed "prat_less_not_sym";
   383 qed "prat_less_not_sym";
   386 
   384 
   387 (* [| x < y;  ~P ==> y < x |] ==> P *)
   385 (* [| x < y;  ~P ==> y < x |] ==> P *)
   388 bind_thm ("prat_less_asym", prat_less_not_sym RS swap);
   386 bind_thm ("prat_less_asym", prat_less_not_sym RS contrapos_np);
   389 
   387 
   390 (* half of positive fraction exists- Gleason p. 120- Proposition 9-2.6(i)*)
   388 (* half of positive fraction exists- Gleason p. 120- Proposition 9-2.6(i)*)
   391 Goal "!(q::prat). EX x. x + x = q";
   389 Goal "!(q::prat). EX x. x + x = q";
   392 by (rtac allI 1);
   390 by (rtac allI 1);
   393 by (res_inst_tac [("z","q")] eq_Abs_prat 1);
   391 by (res_inst_tac [("z","q")] eq_Abs_prat 1);