src/HOL/Real/PRat.ML
changeset 5148 74919e8f221c
parent 5143 b94cd208f073
child 5459 1dbaf888f4e7
equal deleted inserted replaced
5147:825877190618 5148:74919e8f221c
    10 
    10 
    11 (*** Many theorems similar to those in Integ.thy ***)
    11 (*** Many theorems similar to those in Integ.thy ***)
    12 (*** Proving that ratrel is an equivalence relation ***)
    12 (*** Proving that ratrel is an equivalence relation ***)
    13 
    13 
    14 Goal
    14 Goal
    15     "!! x1. [| (x1::pnat) * y2 = x2 * y1; x2 * y3 = x3 * y2 |] \
    15     "[| (x1::pnat) * y2 = x2 * y1; x2 * y3 = x3 * y2 |] \
    16 \            ==> x1 * y3 = x3 * y1";        
    16 \            ==> x1 * y3 = x3 * y1";        
    17 by (res_inst_tac [("k1","y2")] (pnat_mult_cancel1 RS iffD1) 1);
    17 by (res_inst_tac [("k1","y2")] (pnat_mult_cancel1 RS iffD1) 1);
    18 by (auto_tac (claset(), simpset() addsimps [pnat_mult_assoc RS sym]));
    18 by (auto_tac (claset(), simpset() addsimps [pnat_mult_assoc RS sym]));
    19 by (auto_tac (claset(),simpset() addsimps [pnat_mult_commute]));
    19 by (auto_tac (claset(),simpset() addsimps [pnat_mult_commute]));
    20 by (dres_inst_tac [("s","x2 * y3")] sym 1);
    20 by (dres_inst_tac [("s","x2 * y3")] sym 1);
    28     "(((x1,y1),(x2,y2)): ratrel) = (x1 * y2 = x2 * y1)";
    28     "(((x1,y1),(x2,y2)): ratrel) = (x1 * y2 = x2 * y1)";
    29 by (Fast_tac 1);
    29 by (Fast_tac 1);
    30 qed "ratrel_iff";
    30 qed "ratrel_iff";
    31 
    31 
    32 Goalw [ratrel_def]
    32 Goalw [ratrel_def]
    33     "!!x1 x2. [| x1 * y2 = x2 * y1 |] ==> ((x1,y1),(x2,y2)): ratrel";
    33     "[| x1 * y2 = x2 * y1 |] ==> ((x1,y1),(x2,y2)): ratrel";
    34 by (Fast_tac  1);
    34 by (Fast_tac  1);
    35 qed "ratrelI";
    35 qed "ratrelI";
    36 
    36 
    37 Goalw [ratrel_def]
    37 Goalw [ratrel_def]
    38   "p: ratrel --> (EX x1 y1 x2 y2. \
    38   "p: ratrel --> (EX x1 y1 x2 y2. \
   141 
   141 
   142 Goalw [prat_pnat_def] "qinv($# (Abs_pnat 1)) = $#(Abs_pnat 1)";
   142 Goalw [prat_pnat_def] "qinv($# (Abs_pnat 1)) = $#(Abs_pnat 1)";
   143 by (simp_tac (simpset() addsimps [qinv]) 1);
   143 by (simp_tac (simpset() addsimps [qinv]) 1);
   144 qed "qinv_1";
   144 qed "qinv_1";
   145 
   145 
   146 Goal 
   146 Goal "!!(x1::pnat). [| x1 * y2 = x2 * y1 |] ==> \
   147      "!!(x1::pnat). [| x1 * y2 = x2 * y1 |] ==> \
       
   148 \     (x * y1 + x1 * ya) * (ya * y2) = (x * y2 + x2 * ya) * (ya * y1)";
   147 \     (x * y1 + x1 * ya) * (ya * y2) = (x * y2 + x2 * ya) * (ya * y1)";
   149 by (auto_tac (claset() addSIs [pnat_same_multI2],
   148 by (auto_tac (claset() addSIs [pnat_same_multI2],
   150        simpset() addsimps [pnat_add_mult_distrib,
   149        simpset() addsimps [pnat_add_mult_distrib,
   151        pnat_mult_assoc]));
   150        pnat_mult_assoc]));
   152 by (res_inst_tac [("n1","y2")] (pnat_mult_commute RS subst) 1);
   151 by (res_inst_tac [("n1","y2")] (pnat_mult_commute RS subst) 1);
   365 Goalw [prat_less_def]
   364 Goalw [prat_less_def]
   366       "Q1 < (Q2::prat) --> (EX Q3. Q1 + Q3 = Q2)";
   365       "Q1 < (Q2::prat) --> (EX Q3. Q1 + Q3 = Q2)";
   367 by (Fast_tac 1);
   366 by (Fast_tac 1);
   368 qed "prat_lessE_lemma";
   367 qed "prat_lessE_lemma";
   369 
   368 
   370 Goal 
   369 Goal "!!P. [| Q1 < (Q2::prat); \
   371      "!! Q1. [| Q1 < (Q2::prat); \
   370 \             !! (Q3::prat). Q1 + Q3 = Q2 ==> P |] \
   372 \        !! (Q3::prat). Q1 + Q3 = Q2 ==> P |] \
   371 \          ==> P";
   373 \     ==> P";
       
   374 by (dtac (prat_lessE_lemma RS mp) 1);
   372 by (dtac (prat_lessE_lemma RS mp) 1);
   375 by Auto_tac;
   373 by Auto_tac;
   376 qed "prat_lessE";
   374 qed "prat_lessE";
   377 
   375 
   378 (* qless is a strong order i.e nonreflexive and transitive *)
   376 (* qless is a strong order i.e nonreflexive and transitive *)
   379 Goal 
   377 Goal "!!(q1::prat). [| q1 < q2; q2 < q3 |] ==> q1 < q3";
   380      "!!(q1::prat). [| q1 < q2; q2 < q3 |] ==> q1 < q3";
       
   381 by (REPEAT(dtac (prat_lessE_lemma RS mp) 1));
   378 by (REPEAT(dtac (prat_lessE_lemma RS mp) 1));
   382 by (REPEAT(etac exE 1));
   379 by (REPEAT(etac exE 1));
   383 by (hyp_subst_tac 1);
   380 by (hyp_subst_tac 1);
   384 by (res_inst_tac [("Q3.0","Q3 + Q3a")] prat_lessI 1);
   381 by (res_inst_tac [("Q3.0","Q3 + Q3a")] prat_lessI 1);
   385 by (auto_tac (claset(),simpset() addsimps [prat_add_assoc]));
   382 by (auto_tac (claset(),simpset() addsimps [prat_add_assoc]));
   651 by (rtac not_prat_leE 1);
   648 by (rtac not_prat_leE 1);
   652 by (fast_tac (claset() addDs [prat_le_imp_less_or_eq]) 1);
   649 by (fast_tac (claset() addDs [prat_le_imp_less_or_eq]) 1);
   653 qed "not_less_not_eq_prat_less";
   650 qed "not_less_not_eq_prat_less";
   654 
   651 
   655 Goalw [prat_less_def] 
   652 Goalw [prat_less_def] 
   656       "!!x. [| x1 < y1; x2 < y2 |] ==> x1 + x2 < y1 + (y2::prat)";
   653       "[| x1 < y1; x2 < y2 |] ==> x1 + x2 < y1 + (y2::prat)";
   657 by (REPEAT(etac exE 1));
   654 by (REPEAT(etac exE 1));
   658 by (res_inst_tac [("x","T+Ta")] exI 1);
   655 by (res_inst_tac [("x","T+Ta")] exI 1);
   659 by (auto_tac (claset(),simpset() addsimps prat_add_ac));
   656 by (auto_tac (claset(),simpset() addsimps prat_add_ac));
   660 qed "prat_add_less_mono";
   657 qed "prat_add_less_mono";
   661 
   658 
   662 Goalw [prat_less_def] 
   659 Goalw [prat_less_def] 
   663       "!!x. [| x1 < y1; x2 < y2 |] ==> x1 * x2 < y1 * (y2::prat)";
   660       "[| x1 < y1; x2 < y2 |] ==> x1 * x2 < y1 * (y2::prat)";
   664 by (REPEAT(etac exE 1));
   661 by (REPEAT(etac exE 1));
   665 by (res_inst_tac [("x","T*Ta+T*x2+x1*Ta")] exI 1);
   662 by (res_inst_tac [("x","T*Ta+T*x2+x1*Ta")] exI 1);
   666 by (auto_tac (claset(),simpset() addsimps prat_add_ac @ 
   663 by (auto_tac (claset(),simpset() addsimps prat_add_ac @ 
   667     [prat_add_mult_distrib,prat_add_mult_distrib2]));
   664     [prat_add_mult_distrib,prat_add_mult_distrib2]));
   668 qed "prat_mult_less_mono";
   665 qed "prat_mult_less_mono";