src/HOL/Real/PReal.ML
changeset 5148 74919e8f221c
parent 5143 b94cd208f073
child 5459 1dbaf888f4e7
equal deleted inserted replaced
5147:825877190618 5148:74919e8f221c
    48 by (auto_tac (claset() addIs [(equals0I RS sym)],
    48 by (auto_tac (claset() addIs [(equals0I RS sym)],
    49               simpset() addsimps [psubset_def]));
    49               simpset() addsimps [psubset_def]));
    50 qed "mem_Rep_preal_Ex";
    50 qed "mem_Rep_preal_Ex";
    51 
    51 
    52 Goalw [preal_def] 
    52 Goalw [preal_def] 
    53       "!!A. [| {} < A; A < {q::prat. True}; \
    53       "[| {} < A; A < {q::prat. True}; \
    54 \              (!y: A. ((!z. z < y --> z: A) & \
    54 \              (!y: A. ((!z. z < y --> z: A) & \
    55 \                        (? u: A. y < u))) |] ==> A : preal";
    55 \                        (? u: A. y < u))) |] ==> A : preal";
    56 by (Fast_tac 1);
    56 by (Fast_tac 1);
    57 qed "prealI1";
    57 qed "prealI1";
    58     
    58     
    59 Goalw [preal_def] 
    59 Goalw [preal_def] 
    60       "!!A. [| {} < A; A < {q::prat. True}; \
    60       "[| {} < A; A < {q::prat. True}; \
    61 \              !y: A. (!z. z < y --> z: A); \
    61 \              !y: A. (!z. z < y --> z: A); \
    62 \              !y: A. (? u: A. y < u) |] ==> A : preal";
    62 \              !y: A. (? u: A. y < u) |] ==> A : preal";
    63 by (Best_tac 1);
    63 by (Best_tac 1);
    64 qed "prealI2";
    64 qed "prealI2";
    65 
    65 
    66 Goalw [preal_def] 
    66 Goalw [preal_def] 
    67       "!!A. A : preal ==> {} < A & A < {q::prat. True} & \
    67       "A : preal ==> {} < A & A < {q::prat. True} & \
    68 \                         (!y: A. ((!z. z < y --> z: A) & \
    68 \                         (!y: A. ((!z. z < y --> z: A) & \
    69 \                                  (? u: A. y < u)))";
    69 \                                  (? u: A. y < u)))";
    70 by (Fast_tac 1);
    70 by (Fast_tac 1);
    71 qed "prealE_lemma";
    71 qed "prealE_lemma";
    72 
    72 
    74 AddSIs [prealI1,prealI2];
    74 AddSIs [prealI1,prealI2];
    75 
    75 
    76 Addsimps [Abs_preal_inverse];
    76 Addsimps [Abs_preal_inverse];
    77 
    77 
    78 
    78 
    79 Goalw [preal_def] 
    79 Goalw [preal_def] "A : preal ==> {} < A";
    80       "!!A. A : preal ==> {} < A";
       
    81 by (Fast_tac 1);
    80 by (Fast_tac 1);
    82 qed "prealE_lemma1";
    81 qed "prealE_lemma1";
    83 
    82 
    84 Goalw [preal_def] 
    83 Goalw [preal_def] "A : preal ==> A < {q::prat. True}";
    85       "!!A. A : preal ==> A < {q::prat. True}";
       
    86 by (Fast_tac 1);
    84 by (Fast_tac 1);
    87 qed "prealE_lemma2";
    85 qed "prealE_lemma2";
    88 
    86 
    89 Goalw [preal_def] 
    87 Goalw [preal_def] "A : preal ==> !y: A. (!z. z < y --> z: A)";
    90       "!!A. A : preal ==> !y: A. (!z. z < y --> z: A)";
       
    91 by (Fast_tac 1);
    88 by (Fast_tac 1);
    92 qed "prealE_lemma3";
    89 qed "prealE_lemma3";
    93 
    90 
    94 Goal 
    91 Goal "[| A : preal; y: A |] ==> (!z. z < y --> z: A)";
    95       "!!A. [| A : preal; y: A |] ==> (!z. z < y --> z: A)";
       
    96 by (fast_tac (claset() addSDs [prealE_lemma3]) 1);
    92 by (fast_tac (claset() addSDs [prealE_lemma3]) 1);
    97 qed "prealE_lemma3a";
    93 qed "prealE_lemma3a";
    98 
    94 
    99 Goal 
    95 Goal "[| A : preal; y: A; z < y |] ==> z: A";
   100       "!!A. [| A : preal; y: A; z < y |] ==> z: A";
       
   101 by (fast_tac (claset() addSDs [prealE_lemma3a]) 1);
    96 by (fast_tac (claset() addSDs [prealE_lemma3a]) 1);
   102 qed "prealE_lemma3b";
    97 qed "prealE_lemma3b";
   103 
    98 
   104 Goalw [preal_def] 
    99 Goalw [preal_def] "A : preal ==> !y: A. (? u: A. y < u)";
   105       "!!A. A : preal ==> !y: A. (? u: A. y < u)";
       
   106 by (Fast_tac 1);
   100 by (Fast_tac 1);
   107 qed "prealE_lemma4";
   101 qed "prealE_lemma4";
   108 
   102 
   109 Goal 
   103 Goal "[| A : preal; y: A |] ==> ? u: A. y < u";
   110       "!!A. [| A : preal; y: A |] ==> ? u: A. y < u";
       
   111 by (fast_tac (claset() addSDs [prealE_lemma4]) 1);
   104 by (fast_tac (claset() addSDs [prealE_lemma4]) 1);
   112 qed "prealE_lemma4a";
   105 qed "prealE_lemma4a";
   113 
   106 
   114 Goal "? x. x~: Rep_preal X";
   107 Goal "? x. x~: Rep_preal X";
   115 by (cut_inst_tac [("x","X")] Rep_preal 1);
   108 by (cut_inst_tac [("x","X")] Rep_preal 1);
   175 Goalw [preal_less_def]
   168 Goalw [preal_less_def]
   176       "R1 < (R2::preal) --> (Rep_preal(R1) < Rep_preal(R2))";
   169       "R1 < (R2::preal) --> (Rep_preal(R1) < Rep_preal(R2))";
   177 by (Fast_tac  1);
   170 by (Fast_tac  1);
   178 qed "preal_lessE_lemma";
   171 qed "preal_lessE_lemma";
   179 
   172 
   180 Goal 
   173 Goal "!!P. [| R1 < (R2::preal); \
   181      "!! R1. [| R1 < (R2::preal); \
   174 \             (Rep_preal(R1) < Rep_preal(R2)) ==> P |] \
   182 \               (Rep_preal(R1) < Rep_preal(R2)) ==> P |] \
   175 \          ==> P";
   183 \     ==> P";
       
   184 by (dtac (preal_lessE_lemma RS mp) 1);
   176 by (dtac (preal_lessE_lemma RS mp) 1);
   185 by Auto_tac;
   177 by Auto_tac;
   186 qed "preal_lessE";
   178 qed "preal_lessE";
   187 
   179 
   188 (* A positive fraction not in a positive real is an upper bound *)
   180 (* A positive fraction not in a positive real is an upper bound *)
   443 (** Distribution of multiplication across addition **)
   435 (** Distribution of multiplication across addition **)
   444 (** lemmas for the proof **)
   436 (** lemmas for the proof **)
   445 
   437 
   446  (** lemmas **)
   438  (** lemmas **)
   447 Goalw [preal_add_def] 
   439 Goalw [preal_add_def] 
   448       "!!R. z: Rep_preal(R+S) ==> \
   440       "z: Rep_preal(R+S) ==> \
   449 \           ? x: Rep_preal(R). ? y: Rep_preal(S). z = x + y";
   441 \           ? x: Rep_preal(R). ? y: Rep_preal(S). z = x + y";
   450 by (dtac (preal_mem_add_set RS Abs_preal_inverse RS subst) 1);
   442 by (dtac (preal_mem_add_set RS Abs_preal_inverse RS subst) 1);
   451 by (Fast_tac 1);
   443 by (Fast_tac 1);
   452 qed "mem_Rep_preal_addD";
   444 qed "mem_Rep_preal_addD";
   453 
   445 
   454 Goalw [preal_add_def] 
   446 Goalw [preal_add_def] 
   455       "!!R. ? x: Rep_preal(R). ? y: Rep_preal(S). z = x + y \
   447       "? x: Rep_preal(R). ? y: Rep_preal(S). z = x + y \
   456 \      ==> z: Rep_preal(R+S)";
   448 \      ==> z: Rep_preal(R+S)";
   457 by (rtac (preal_mem_add_set RS Abs_preal_inverse RS ssubst) 1);
   449 by (rtac (preal_mem_add_set RS Abs_preal_inverse RS ssubst) 1);
   458 by (Fast_tac 1);
   450 by (Fast_tac 1);
   459 qed "mem_Rep_preal_addI";
   451 qed "mem_Rep_preal_addI";
   460 
   452 
   462 \                                 ? y: Rep_preal(S). z = x + y)";
   454 \                                 ? y: Rep_preal(S). z = x + y)";
   463 by (fast_tac (claset() addSIs [mem_Rep_preal_addD,mem_Rep_preal_addI]) 1);
   455 by (fast_tac (claset() addSIs [mem_Rep_preal_addD,mem_Rep_preal_addI]) 1);
   464 qed "mem_Rep_preal_add_iff";
   456 qed "mem_Rep_preal_add_iff";
   465 
   457 
   466 Goalw [preal_mult_def] 
   458 Goalw [preal_mult_def] 
   467       "!!R. z: Rep_preal(R*S) ==> \
   459       "z: Rep_preal(R*S) ==> \
   468 \           ? x: Rep_preal(R). ? y: Rep_preal(S). z = x * y";
   460 \           ? x: Rep_preal(R). ? y: Rep_preal(S). z = x * y";
   469 by (dtac (preal_mem_mult_set RS Abs_preal_inverse RS subst) 1);
   461 by (dtac (preal_mem_mult_set RS Abs_preal_inverse RS subst) 1);
   470 by (Fast_tac 1);
   462 by (Fast_tac 1);
   471 qed "mem_Rep_preal_multD";
   463 qed "mem_Rep_preal_multD";
   472 
   464 
   473 Goalw [preal_mult_def] 
   465 Goalw [preal_mult_def] 
   474       "!!R. ? x: Rep_preal(R). ? y: Rep_preal(S). z = x * y \
   466       "? x: Rep_preal(R). ? y: Rep_preal(S). z = x * y \
   475 \      ==> z: Rep_preal(R*S)";
   467 \      ==> z: Rep_preal(R*S)";
   476 by (rtac (preal_mem_mult_set RS Abs_preal_inverse RS ssubst) 1);
   468 by (rtac (preal_mem_mult_set RS Abs_preal_inverse RS ssubst) 1);
   477 by (Fast_tac 1);
   469 by (Fast_tac 1);
   478 qed "mem_Rep_preal_multI";
   470 qed "mem_Rep_preal_multI";
   479 
   471 
   772 qed "preal_self_less_add_right";
   764 qed "preal_self_less_add_right";
   773 
   765 
   774 (*** Properties of <= ***)
   766 (*** Properties of <= ***)
   775 
   767 
   776 Goalw [preal_le_def,psubset_def,preal_less_def] 
   768 Goalw [preal_le_def,psubset_def,preal_less_def] 
   777                      "!!w. z<=w ==> ~(w<(z::preal))";
   769                      "z<=w ==> ~(w<(z::preal))";
   778 by (auto_tac  (claset() addDs [equalityI],simpset()));
   770 by (auto_tac  (claset() addDs [equalityI],simpset()));
   779 qed "preal_leD";
   771 qed "preal_leD";
   780 
   772 
   781 val preal_leE = make_elim preal_leD;
   773 val preal_leE = make_elim preal_leD;
   782 
   774 
   783 Goalw [preal_le_def,psubset_def,preal_less_def]
   775 Goalw [preal_le_def,psubset_def,preal_less_def]
   784                    "!!z. ~ z <= w ==> w<(z::preal)";
   776                    "~ z <= w ==> w<(z::preal)";
   785 by (cut_inst_tac [("r1.0","w"),("r2.0","z")] preal_linear 1);
   777 by (cut_inst_tac [("r1.0","w"),("r2.0","z")] preal_linear 1);
   786 by (auto_tac  (claset(),simpset() addsimps [preal_less_def,psubset_def]));
   778 by (auto_tac  (claset(),simpset() addsimps [preal_less_def,psubset_def]));
   787 qed "not_preal_leE";
   779 qed "not_preal_leE";
   788 		       
   780 		       
   789 Goal "~(w < z) ==> z <= (w::preal)";
   781 Goal "~(w < z) ==> z <= (w::preal)";
   793 Goal "(~(w < z)) = (z <= (w::preal))";
   785 Goal "(~(w < z)) = (z <= (w::preal))";
   794 by (fast_tac (claset() addSIs [preal_leI,preal_leD]) 1);
   786 by (fast_tac (claset() addSIs [preal_leI,preal_leD]) 1);
   795 qed "preal_less_le_iff";
   787 qed "preal_less_le_iff";
   796 
   788 
   797 Goalw [preal_le_def,preal_less_def,psubset_def] 
   789 Goalw [preal_le_def,preal_less_def,psubset_def] 
   798                   "!!z. z < w ==> z <= (w::preal)";
   790                   "z < w ==> z <= (w::preal)";
   799 by (Fast_tac 1);
   791 by (Fast_tac 1);
   800 qed "preal_less_imp_le";
   792 qed "preal_less_imp_le";
   801 
   793 
   802 Goalw [preal_le_def,preal_less_def,psubset_def] 
   794 Goalw [preal_le_def,preal_less_def,psubset_def] 
   803                       "!!(x::preal). x <= y ==> x < y | x = y";
   795                       "!!(x::preal). x <= y ==> x < y | x = y";
   876 by (auto_tac (claset() addDs [subsetD],simpset()));
   868 by (auto_tac (claset() addDs [subsetD],simpset()));
   877 qed "psubsetD";
   869 qed "psubsetD";
   878 
   870 
   879 (** Part 1 of Dedekind sections def **)
   871 (** Part 1 of Dedekind sections def **)
   880 Goalw [preal_less_def]
   872 Goalw [preal_less_def]
   881      "!!A. A < B ==> \
   873      "A < B ==> \
   882 \     ? q. q : {d. ? n. n ~: Rep_preal(A) & n + d : Rep_preal(B)}";
   874 \     ? q. q : {d. ? n. n ~: Rep_preal(A) & n + d : Rep_preal(B)}";
   883 by (EVERY1[dtac lemma_psubset_mem, etac exE, etac conjE]);
   875 by (EVERY1[dtac lemma_psubset_mem, etac exE, etac conjE]);
   884 by (dres_inst_tac [("x1","B")] (Rep_preal RS prealE_lemma4a) 1);
   876 by (dres_inst_tac [("x1","B")] (Rep_preal RS prealE_lemma4a) 1);
   885 by (auto_tac (claset(),simpset() addsimps [prat_less_def]));
   877 by (auto_tac (claset(),simpset() addsimps [prat_less_def]));
   886 qed "lemma_ex_mem_less_left_add1";
   878 qed "lemma_ex_mem_less_left_add1";
   887 
   879 
   888 Goal
   880 Goal
   889      "!!A. A < B ==> \
   881      "A < B ==> \
   890 \       {} < {d. ? n. n ~: Rep_preal(A) & n + d : Rep_preal(B)}";
   882 \       {} < {d. ? n. n ~: Rep_preal(A) & n + d : Rep_preal(B)}";
   891 by (dtac lemma_ex_mem_less_left_add1 1);
   883 by (dtac lemma_ex_mem_less_left_add1 1);
   892 by (auto_tac (claset() addSIs [psubsetI] addEs [equalityCE],simpset()));
   884 by (auto_tac (claset() addSIs [psubsetI] addEs [equalityCE],simpset()));
   893 qed "preal_less_set_not_empty";
   885 qed "preal_less_set_not_empty";
   894 
   886 
  1072     preal_add_left_less_cancel] 1));
  1064     preal_add_left_less_cancel] 1));
  1073 qed "preal_add_less_iff2";
  1065 qed "preal_add_less_iff2";
  1074 
  1066 
  1075 Addsimps [preal_add_less_iff2];
  1067 Addsimps [preal_add_less_iff2];
  1076 
  1068 
  1077 Goal 
  1069 Goal "[| x1 < y1; x2 < y2 |] ==> x1 + x2 < y1 + (y2::preal)";
  1078       "!!x1. [| x1 < y1; x2 < y2 |] ==> x1 + x2 < y1 + (y2::preal)";
       
  1079 by (auto_tac (claset() addSDs [preal_less_add_left_Ex],
  1070 by (auto_tac (claset() addSDs [preal_less_add_left_Ex],
  1080     simpset() addsimps  preal_add_ac));
  1071     simpset() addsimps  preal_add_ac));
  1081 by (rtac (preal_add_assoc RS subst) 1);
  1072 by (rtac (preal_add_assoc RS subst) 1);
  1082 by (rtac preal_self_less_add_right 1);
  1073 by (rtac preal_self_less_add_right 1);
  1083 qed "preal_add_less_mono";
  1074 qed "preal_add_less_mono";
  1084 
  1075 
  1085 Goal 
  1076 Goal "[| x1 < y1; x2 < y2 |] ==> x1 * x2 < y1 * (y2::preal)";
  1086       "!!x1. [| x1 < y1; x2 < y2 |] ==> x1 * x2 < y1 * (y2::preal)";
       
  1087 by (auto_tac (claset() addSDs [preal_less_add_left_Ex],
  1077 by (auto_tac (claset() addSDs [preal_less_add_left_Ex],
  1088               simpset() addsimps [preal_add_mult_distrib,
  1078               simpset() addsimps [preal_add_mult_distrib,
  1089               preal_add_mult_distrib2,preal_self_less_add_left,
  1079               preal_add_mult_distrib2,preal_self_less_add_left,
  1090               preal_add_assoc] @ preal_mult_ac));
  1080               preal_add_assoc] @ preal_mult_ac));
  1091 qed "preal_mult_less_mono";
  1081 qed "preal_mult_less_mono";