src/HOL/Hyperreal/NthRoot.thy
author avigad
Tue Jul 12 17:56:03 2005 +0200 (2005-07-12)
changeset 16775 c1b87ef4a1c3
parent 15140 322485b816ac
child 18585 5d379fe2eb74
permissions -rw-r--r--
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
added lemmas to Ring_and_Field.thy (reasoning about signs, fractions, etc.)
renamed simplification rules for abs (abs_of_pos, etc.)
renamed rules for multiplication and signs (mult_pos_pos, etc.)
moved lemmas involving fractions from NatSimprocs.thy
added setsum_mono3 to FiniteSet.thy
added simplification rules for powers to Parity.thy
paulson@12196
     1
(*  Title       : NthRoot.thy
paulson@12196
     2
    Author      : Jacques D. Fleuriot
paulson@12196
     3
    Copyright   : 1998  University of Cambridge
paulson@14477
     4
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
paulson@12196
     5
*)
paulson@12196
     6
paulson@14324
     7
header{*Existence of Nth Root*}
paulson@14324
     8
nipkow@15131
     9
theory NthRoot
nipkow@15140
    10
imports SEQ HSeries
nipkow@15131
    11
begin
paulson@14324
    12
wenzelm@14767
    13
text {*
wenzelm@14767
    14
  Various lemmas needed for this result. We follow the proof given by
wenzelm@14767
    15
  John Lindsay Orr (\texttt{jorr@math.unl.edu}) in his Analysis
wenzelm@14767
    16
  Webnotes available at \url{http://www.math.unl.edu/~webnotes}.
wenzelm@14767
    17
wenzelm@14767
    18
  Lemmas about sequences of reals are used to reach the result.
wenzelm@14767
    19
*}
paulson@14324
    20
paulson@14324
    21
lemma lemma_nth_realpow_non_empty:
paulson@14324
    22
     "[| (0::real) < a; 0 < n |] ==> \<exists>s. s : {x. x ^ n <= a & 0 < x}"
paulson@14324
    23
apply (case_tac "1 <= a")
paulson@14477
    24
apply (rule_tac x = 1 in exI)
paulson@14334
    25
apply (drule_tac [2] linorder_not_le [THEN iffD1])
paulson@14477
    26
apply (drule_tac [2] less_not_refl2 [THEN not0_implies_Suc], simp) 
paulson@14348
    27
apply (force intro!: realpow_Suc_le_self simp del: realpow_Suc)
paulson@14324
    28
done
paulson@14324
    29
paulson@14348
    30
text{*Used only just below*}
paulson@14348
    31
lemma realpow_ge_self2: "[| (1::real) \<le> r; 0 < n |] ==> r \<le> r ^ n"
paulson@14348
    32
by (insert power_increasing [of 1 n r], simp)
paulson@14348
    33
paulson@14324
    34
lemma lemma_nth_realpow_isUb_ex:
paulson@14324
    35
     "[| (0::real) < a; 0 < n |]  
paulson@14324
    36
      ==> \<exists>u. isUb (UNIV::real set) {x. x ^ n <= a & 0 < x} u"
paulson@14324
    37
apply (case_tac "1 <= a")
paulson@14477
    38
apply (rule_tac x = a in exI)
paulson@14334
    39
apply (drule_tac [2] linorder_not_le [THEN iffD1])
paulson@14477
    40
apply (rule_tac [2] x = 1 in exI)
paulson@14477
    41
apply (rule_tac [!] setleI [THEN isUbI], safe)
paulson@14324
    42
apply (simp_all (no_asm))
paulson@14324
    43
apply (rule_tac [!] ccontr)
paulson@14334
    44
apply (drule_tac [!] linorder_not_le [THEN iffD1])
paulson@14477
    45
apply (drule realpow_ge_self2, assumption)
paulson@14477
    46
apply (drule_tac n = n in realpow_less)
paulson@14324
    47
apply (assumption+)
paulson@14477
    48
apply (drule real_le_trans, assumption)
paulson@14477
    49
apply (drule_tac y = "y ^ n" in order_less_le_trans, assumption, simp) 
paulson@14477
    50
apply (drule_tac n = n in zero_less_one [THEN realpow_less], auto)
paulson@14324
    51
done
paulson@14324
    52
paulson@14324
    53
lemma nth_realpow_isLub_ex:
paulson@14324
    54
     "[| (0::real) < a; 0 < n |]  
paulson@14324
    55
      ==> \<exists>u. isLub (UNIV::real set) {x. x ^ n <= a & 0 < x} u"
paulson@14365
    56
by (blast intro: lemma_nth_realpow_isUb_ex lemma_nth_realpow_non_empty reals_complete)
paulson@14365
    57
paulson@14324
    58
 
paulson@14324
    59
subsection{*First Half -- Lemmas First*}
paulson@14324
    60
paulson@14324
    61
lemma lemma_nth_realpow_seq:
paulson@14324
    62
     "isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u  
paulson@14324
    63
           ==> u + inverse(real (Suc k)) ~: {x. x ^ n <= a & 0 < x}"
paulson@14477
    64
apply (safe, drule isLubD2, blast)
paulson@14365
    65
apply (simp add: linorder_not_less [symmetric])
paulson@14324
    66
done
paulson@14324
    67
paulson@14324
    68
lemma lemma_nth_realpow_isLub_gt_zero:
paulson@14324
    69
     "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u;  
paulson@14324
    70
         0 < a; 0 < n |] ==> 0 < u"
paulson@14477
    71
apply (drule lemma_nth_realpow_non_empty, auto)
paulson@14477
    72
apply (drule_tac y = s in isLub_isUb [THEN isUbD])
paulson@14324
    73
apply (auto intro: order_less_le_trans)
paulson@14324
    74
done
paulson@14324
    75
paulson@14324
    76
lemma lemma_nth_realpow_isLub_ge:
paulson@14324
    77
     "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u;  
paulson@14324
    78
         0 < a; 0 < n |] ==> ALL k. a <= (u + inverse(real (Suc k))) ^ n"
paulson@14477
    79
apply safe
paulson@14477
    80
apply (frule lemma_nth_realpow_seq, safe)
paulson@15085
    81
apply (auto elim: order_less_asym simp add: linorder_not_less [symmetric]
paulson@15085
    82
            iff: real_0_less_add_iff) --{*legacy iff rule!*}
paulson@14365
    83
apply (simp add: linorder_not_less)
paulson@14324
    84
apply (rule order_less_trans [of _ 0])
paulson@14325
    85
apply (auto intro: lemma_nth_realpow_isLub_gt_zero)
paulson@14324
    86
done
paulson@14324
    87
paulson@14324
    88
text{*First result we want*}
paulson@14324
    89
lemma realpow_nth_ge:
paulson@14324
    90
     "[| (0::real) < a; 0 < n;  
paulson@14324
    91
     isLub (UNIV::real set)  
paulson@14324
    92
     {x. x ^ n <= a & 0 < x} u |] ==> a <= u ^ n"
paulson@14477
    93
apply (frule lemma_nth_realpow_isLub_ge, safe)
paulson@14324
    94
apply (rule LIMSEQ_inverse_real_of_nat_add [THEN LIMSEQ_pow, THEN LIMSEQ_le_const])
paulson@14334
    95
apply (auto simp add: real_of_nat_def)
paulson@14324
    96
done
paulson@14324
    97
paulson@14324
    98
subsection{*Second Half*}
paulson@14324
    99
paulson@14324
   100
lemma less_isLub_not_isUb:
paulson@14324
   101
     "[| isLub (UNIV::real set) S u; x < u |]  
paulson@14324
   102
           ==> ~ isUb (UNIV::real set) S x"
paulson@14477
   103
apply safe
paulson@14477
   104
apply (drule isLub_le_isUb, assumption)
paulson@14477
   105
apply (drule order_less_le_trans, auto)
paulson@14324
   106
done
paulson@14324
   107
paulson@14324
   108
lemma not_isUb_less_ex:
paulson@14324
   109
     "~ isUb (UNIV::real set) S u ==> \<exists>x \<in> S. u < x"
paulson@14477
   110
apply (rule ccontr, erule swap)
paulson@14324
   111
apply (rule setleI [THEN isUbI])
paulson@14365
   112
apply (auto simp add: linorder_not_less [symmetric])
paulson@14324
   113
done
paulson@14324
   114
paulson@14325
   115
lemma real_mult_less_self: "0 < r ==> r * (1 + -inverse(real (Suc n))) < r"
paulson@14334
   116
apply (simp (no_asm) add: right_distrib)
paulson@14334
   117
apply (rule add_less_cancel_left [of "-r", THEN iffD1])
avigad@16775
   118
apply (auto intro: mult_pos_pos
paulson@14334
   119
            simp add: add_assoc [symmetric] neg_less_0_iff_less)
paulson@14325
   120
done
paulson@14325
   121
paulson@14325
   122
lemma real_mult_add_one_minus_ge_zero:
paulson@14325
   123
     "0 < r ==>  0 <= r*(1 + -inverse(real (Suc n)))"
paulson@15085
   124
by (simp add: zero_le_mult_iff real_of_nat_inverse_le_iff real_0_le_add_iff)
paulson@14325
   125
paulson@14324
   126
lemma lemma_nth_realpow_isLub_le:
paulson@14324
   127
     "[| isLub (UNIV::real set) {x. x ^ n <= a & (0::real) < x} u;  
paulson@14325
   128
       0 < a; 0 < n |] ==> ALL k. (u*(1 + -inverse(real (Suc k)))) ^ n <= a"
paulson@14477
   129
apply safe
paulson@14324
   130
apply (frule less_isLub_not_isUb [THEN not_isUb_less_ex])
paulson@14477
   131
apply (rule_tac n = k in real_mult_less_self)
paulson@14477
   132
apply (blast intro: lemma_nth_realpow_isLub_gt_zero, safe)
paulson@14477
   133
apply (drule_tac n = k in
paulson@14477
   134
        lemma_nth_realpow_isLub_gt_zero [THEN real_mult_add_one_minus_ge_zero], assumption+)
paulson@14348
   135
apply (blast intro: order_trans order_less_imp_le power_mono) 
paulson@14324
   136
done
paulson@14324
   137
paulson@14324
   138
text{*Second result we want*}
paulson@14324
   139
lemma realpow_nth_le:
paulson@14324
   140
     "[| (0::real) < a; 0 < n;  
paulson@14324
   141
     isLub (UNIV::real set)  
paulson@14324
   142
     {x. x ^ n <= a & 0 < x} u |] ==> u ^ n <= a"
paulson@14477
   143
apply (frule lemma_nth_realpow_isLub_le, safe)
paulson@14348
   144
apply (rule LIMSEQ_inverse_real_of_nat_add_minus_mult
paulson@14348
   145
                [THEN LIMSEQ_pow, THEN LIMSEQ_le_const2])
paulson@14334
   146
apply (auto simp add: real_of_nat_def)
paulson@14324
   147
done
paulson@14324
   148
paulson@14348
   149
text{*The theorem at last!*}
paulson@14324
   150
lemma realpow_nth: "[| (0::real) < a; 0 < n |] ==> \<exists>r. r ^ n = a"
paulson@14477
   151
apply (frule nth_realpow_isLub_ex, auto)
paulson@14477
   152
apply (auto intro: realpow_nth_le realpow_nth_ge order_antisym)
paulson@14324
   153
done
paulson@14324
   154
paulson@14324
   155
(* positive only *)
paulson@14324
   156
lemma realpow_pos_nth: "[| (0::real) < a; 0 < n |] ==> \<exists>r. 0 < r & r ^ n = a"
paulson@14477
   157
apply (frule nth_realpow_isLub_ex, auto)
paulson@14477
   158
apply (auto intro: realpow_nth_le realpow_nth_ge order_antisym lemma_nth_realpow_isLub_gt_zero)
paulson@14324
   159
done
paulson@14324
   160
paulson@14324
   161
lemma realpow_pos_nth2: "(0::real) < a  ==> \<exists>r. 0 < r & r ^ Suc n = a"
paulson@14477
   162
by (blast intro: realpow_pos_nth)
paulson@14324
   163
paulson@14324
   164
(* uniqueness of nth positive root *)
paulson@14324
   165
lemma realpow_pos_nth_unique:
paulson@14324
   166
     "[| (0::real) < a; 0 < n |] ==> EX! r. 0 < r & r ^ n = a"
paulson@14324
   167
apply (auto intro!: realpow_pos_nth)
paulson@14477
   168
apply (cut_tac x = r and y = y in linorder_less_linear, auto)
paulson@14477
   169
apply (drule_tac x = r in realpow_less)
paulson@14477
   170
apply (drule_tac [4] x = y in realpow_less, auto)
paulson@14324
   171
done
paulson@14324
   172
paulson@14324
   173
ML
paulson@14324
   174
{*
paulson@14324
   175
val nth_realpow_isLub_ex = thm"nth_realpow_isLub_ex";
paulson@14324
   176
val realpow_nth_ge = thm"realpow_nth_ge";
paulson@14324
   177
val less_isLub_not_isUb = thm"less_isLub_not_isUb";
paulson@14324
   178
val not_isUb_less_ex = thm"not_isUb_less_ex";
paulson@14324
   179
val realpow_nth_le = thm"realpow_nth_le";
paulson@14324
   180
val realpow_nth = thm"realpow_nth";
paulson@14324
   181
val realpow_pos_nth = thm"realpow_pos_nth";
paulson@14324
   182
val realpow_pos_nth2 = thm"realpow_pos_nth2";
paulson@14324
   183
val realpow_pos_nth_unique = thm"realpow_pos_nth_unique";
paulson@14324
   184
*}
paulson@14324
   185
paulson@14324
   186
end