author  huffman 
Tue, 29 May 2007 20:31:42 +0200  
changeset 23122  3d853d6f2f7d 
parent 23069  cdfff0241c12 
child 23257  9117e228a8e3 
permissions  rwrr 
12196  1 
(* Title : NthRoot.thy 
2 
Author : Jacques D. Fleuriot 

3 
Copyright : 1998 University of Cambridge 

14477  4 
Conversion to Isar and new proofs by Lawrence C Paulson, 2004 
12196  5 
*) 
6 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

7 
header {* Nth Roots of Real Numbers *} 
14324  8 

15131  9 
theory NthRoot 
23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

10 
imports SEQ Parity Deriv 
15131  11 
begin 
14324  12 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

13 
subsection {* Existence of Nth Root *} 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

14 

23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

15 
text {* Existence follows from the Intermediate Value Theorem *} 
14324  16 

23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

17 
lemma realpow_pos_nth: 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

18 
assumes n: "0 < n" 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

19 
assumes a: "0 < a" 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

20 
shows "\<exists>r>0. r ^ n = (a::real)" 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

21 
proof  
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

22 
have "\<exists>r\<ge>0. r \<le> (max 1 a) \<and> r ^ n = a" 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

23 
proof (rule IVT) 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

24 
show "0 ^ n \<le> a" using n a by (simp add: power_0_left) 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

25 
show "0 \<le> max 1 a" by simp 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

26 
from n have n1: "1 \<le> n" by simp 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

27 
have "a \<le> max 1 a ^ 1" by simp 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

28 
also have "max 1 a ^ 1 \<le> max 1 a ^ n" 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

29 
using n1 by (rule power_increasing, simp) 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

30 
finally show "a \<le> max 1 a ^ n" . 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

31 
show "\<forall>r. 0 \<le> r \<and> r \<le> max 1 a \<longrightarrow> isCont (\<lambda>x. x ^ n) r" 
23069
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
huffman
parents:
23049
diff
changeset

32 
by (simp add: isCont_power) 
23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

33 
qed 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

34 
then obtain r where r: "0 \<le> r \<and> r ^ n = a" by fast 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

35 
with n a have "r \<noteq> 0" by (auto simp add: power_0_left) 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

36 
with r have "0 < r \<and> r ^ n = a" by simp 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

37 
thus ?thesis .. 
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

38 
qed 
14325  39 

23047  40 
(* Used by Integration/RealRandVar.thy in AFP *) 
41 
lemma realpow_pos_nth2: "(0::real) < a \<Longrightarrow> \<exists>r>0. r ^ Suc n = a" 

42 
by (blast intro: realpow_pos_nth) 

43 

23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

44 
text {* Uniqueness of nth positive root *} 
14324  45 

46 
lemma realpow_pos_nth_unique: 

23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

47 
"\<lbrakk>0 < n; 0 < a\<rbrakk> \<Longrightarrow> \<exists>!r. 0 < r \<and> r ^ n = (a::real)" 
14324  48 
apply (auto intro!: realpow_pos_nth) 
23009
01c295dd4a36
Prove existence of nth roots using Intermediate Value Theorem
huffman
parents:
22968
diff
changeset

49 
apply (rule_tac n=n in power_eq_imp_eq_base, simp_all) 
14324  50 
done 
51 

20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

52 
subsection {* Nth Root *} 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

53 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

54 
text {* We define roots of negative reals such that 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

55 
@{term "root n ( x) =  root n x"}. This allows 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

56 
us to omit side conditions from many theorems. *} 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

57 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

58 
definition 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

59 
root :: "[nat, real] \<Rightarrow> real" where 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

60 
"root n x = (if 0 < x then (THE u. 0 < u \<and> u ^ n = x) else 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

61 
if x < 0 then  (THE u. 0 < u \<and> u ^ n =  x) else 0)" 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

62 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

63 
lemma real_root_zero [simp]: "root n 0 = 0" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

64 
unfolding root_def by simp 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

65 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

66 
lemma real_root_minus: "0 < n \<Longrightarrow> root n ( x) =  root n x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

67 
unfolding root_def by simp 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

68 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

69 
lemma real_root_gt_zero: "\<lbrakk>0 < n; 0 < x\<rbrakk> \<Longrightarrow> 0 < root n x" 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

70 
apply (simp add: root_def) 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

71 
apply (drule (1) realpow_pos_nth_unique) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

72 
apply (erule theI' [THEN conjunct1]) 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

73 
done 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

74 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

75 
lemma real_root_pow_pos: (* TODO: rename *) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

76 
"\<lbrakk>0 < n; 0 < x\<rbrakk> \<Longrightarrow> root n x ^ n = x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

77 
apply (simp add: root_def) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

78 
apply (drule (1) realpow_pos_nth_unique) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

79 
apply (erule theI' [THEN conjunct2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

80 
done 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

81 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

82 
lemma real_root_pow_pos2 [simp]: (* TODO: rename *) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

83 
"\<lbrakk>0 < n; 0 \<le> x\<rbrakk> \<Longrightarrow> root n x ^ n = x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

84 
by (auto simp add: order_le_less real_root_pow_pos) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

85 

23046  86 
lemma odd_pos: "odd (n::nat) \<Longrightarrow> 0 < n" 
87 
by (cases n, simp_all) 

88 

89 
lemma odd_real_root_pow: "odd n \<Longrightarrow> root n x ^ n = x" 

90 
apply (rule_tac x=0 and y=x in linorder_le_cases) 

91 
apply (erule (1) real_root_pow_pos2 [OF odd_pos]) 

92 
apply (subgoal_tac "root n ( x) ^ n =  x") 

93 
apply (simp add: real_root_minus odd_pos) 

94 
apply (simp add: odd_pos) 

95 
done 

96 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

97 
lemma real_root_ge_zero: "\<lbrakk>0 < n; 0 \<le> x\<rbrakk> \<Longrightarrow> 0 \<le> root n x" 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

98 
by (auto simp add: order_le_less real_root_gt_zero) 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

99 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

100 
lemma real_root_power_cancel: "\<lbrakk>0 < n; 0 \<le> x\<rbrakk> \<Longrightarrow> root n (x ^ n) = x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

101 
apply (subgoal_tac "0 \<le> x ^ n") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

102 
apply (subgoal_tac "0 \<le> root n (x ^ n)") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

103 
apply (subgoal_tac "root n (x ^ n) ^ n = x ^ n") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

104 
apply (erule (3) power_eq_imp_eq_base) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

105 
apply (erule (1) real_root_pow_pos2) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

106 
apply (erule (1) real_root_ge_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

107 
apply (erule zero_le_power) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

108 
done 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

109 

23046  110 
lemma odd_real_root_power_cancel: "odd n \<Longrightarrow> root n (x ^ n) = x" 
111 
apply (rule_tac x=0 and y=x in linorder_le_cases) 

112 
apply (erule (1) real_root_power_cancel [OF odd_pos]) 

113 
apply (subgoal_tac "root n (( x) ^ n) =  x") 

114 
apply (simp add: real_root_minus odd_pos) 

115 
apply (erule real_root_power_cancel [OF odd_pos], simp) 

116 
done 

117 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

118 
lemma real_root_pos_unique: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

119 
"\<lbrakk>0 < n; 0 \<le> y; y ^ n = x\<rbrakk> \<Longrightarrow> root n x = y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

120 
by (erule subst, rule real_root_power_cancel) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

121 

23046  122 
lemma odd_real_root_unique: 
123 
"\<lbrakk>odd n; y ^ n = x\<rbrakk> \<Longrightarrow> root n x = y" 

124 
by (erule subst, rule odd_real_root_power_cancel) 

125 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

126 
lemma real_root_one [simp]: "0 < n \<Longrightarrow> root n 1 = 1" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

127 
by (simp add: real_root_pos_unique) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

128 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

129 
text {* Root function is strictly monotonic, hence injective *} 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

130 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

131 
lemma real_root_less_mono_lemma: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

132 
"\<lbrakk>0 < n; 0 \<le> x; x < y\<rbrakk> \<Longrightarrow> root n x < root n y" 
22856  133 
apply (subgoal_tac "0 \<le> y") 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

134 
apply (subgoal_tac "root n x ^ n < root n y ^ n") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

135 
apply (erule power_less_imp_less_base) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

136 
apply (erule (1) real_root_ge_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

137 
apply simp 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

138 
apply simp 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

139 
done 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

140 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

141 
lemma real_root_less_mono: "\<lbrakk>0 < n; x < y\<rbrakk> \<Longrightarrow> root n x < root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

142 
apply (cases "0 \<le> x") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

143 
apply (erule (2) real_root_less_mono_lemma) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

144 
apply (cases "0 \<le> y") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

145 
apply (rule_tac y=0 in order_less_le_trans) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

146 
apply (subgoal_tac "0 < root n ( x)") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

147 
apply (simp add: real_root_minus) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

148 
apply (simp add: real_root_gt_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

149 
apply (simp add: real_root_ge_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

150 
apply (subgoal_tac "root n ( y) < root n ( x)") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

151 
apply (simp add: real_root_minus) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

152 
apply (simp add: real_root_less_mono_lemma) 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

153 
done 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

154 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

155 
lemma real_root_le_mono: "\<lbrakk>0 < n; x \<le> y\<rbrakk> \<Longrightarrow> root n x \<le> root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

156 
by (auto simp add: order_le_less real_root_less_mono) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

157 

22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

158 
lemma real_root_less_iff [simp]: 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

159 
"0 < n \<Longrightarrow> (root n x < root n y) = (x < y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

160 
apply (cases "x < y") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

161 
apply (simp add: real_root_less_mono) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

162 
apply (simp add: linorder_not_less real_root_le_mono) 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

163 
done 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

164 

d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

165 
lemma real_root_le_iff [simp]: 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

166 
"0 < n \<Longrightarrow> (root n x \<le> root n y) = (x \<le> y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

167 
apply (cases "x \<le> y") 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

168 
apply (simp add: real_root_le_mono) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

169 
apply (simp add: linorder_not_le real_root_less_mono) 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

170 
done 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

171 

d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

172 
lemma real_root_eq_iff [simp]: 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

173 
"0 < n \<Longrightarrow> (root n x = root n y) = (x = y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

174 
by (simp add: order_eq_iff) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

175 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

176 
lemmas real_root_gt_0_iff [simp] = real_root_less_iff [where x=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

177 
lemmas real_root_lt_0_iff [simp] = real_root_less_iff [where y=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

178 
lemmas real_root_ge_0_iff [simp] = real_root_le_iff [where x=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

179 
lemmas real_root_le_0_iff [simp] = real_root_le_iff [where y=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

180 
lemmas real_root_eq_0_iff [simp] = real_root_eq_iff [where y=0, simplified] 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

181 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

182 
text {* Roots of multiplication and division *} 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

183 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

184 
lemma real_root_mult_lemma: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

185 
"\<lbrakk>0 < n; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> root n (x * y) = root n x * root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

186 
by (simp add: real_root_pos_unique mult_nonneg_nonneg power_mult_distrib) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

187 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

188 
lemma real_root_inverse_lemma: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

189 
"\<lbrakk>0 < n; 0 \<le> x\<rbrakk> \<Longrightarrow> root n (inverse x) = inverse (root n x)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

190 
by (simp add: real_root_pos_unique power_inverse [symmetric]) 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

191 

d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

192 
lemma real_root_mult: 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

193 
assumes n: "0 < n" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

194 
shows "root n (x * y) = root n x * root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

195 
proof (rule linorder_le_cases, rule_tac [!] linorder_le_cases) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

196 
assume "0 \<le> x" and "0 \<le> y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

197 
thus ?thesis by (rule real_root_mult_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

198 
next 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

199 
assume "0 \<le> x" and "y \<le> 0" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

200 
hence "0 \<le> x" and "0 \<le>  y" by simp_all 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

201 
hence "root n (x *  y) = root n x * root n ( y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

202 
by (rule real_root_mult_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

203 
thus ?thesis by (simp add: real_root_minus [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

204 
next 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

205 
assume "x \<le> 0" and "0 \<le> y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

206 
hence "0 \<le>  x" and "0 \<le> y" by simp_all 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

207 
hence "root n ( x * y) = root n ( x) * root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

208 
by (rule real_root_mult_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

209 
thus ?thesis by (simp add: real_root_minus [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

210 
next 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

211 
assume "x \<le> 0" and "y \<le> 0" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

212 
hence "0 \<le>  x" and "0 \<le>  y" by simp_all 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

213 
hence "root n ( x *  y) = root n ( x) * root n ( y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

214 
by (rule real_root_mult_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

215 
thus ?thesis by (simp add: real_root_minus [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

216 
qed 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

217 

d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

218 
lemma real_root_inverse: 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

219 
assumes n: "0 < n" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

220 
shows "root n (inverse x) = inverse (root n x)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

221 
proof (rule linorder_le_cases) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

222 
assume "0 \<le> x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

223 
thus ?thesis by (rule real_root_inverse_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

224 
next 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

225 
assume "x \<le> 0" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

226 
hence "0 \<le>  x" by simp 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

227 
hence "root n (inverse ( x)) = inverse (root n ( x))" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

228 
by (rule real_root_inverse_lemma [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

229 
thus ?thesis by (simp add: real_root_minus [OF n]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

230 
qed 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

231 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

232 
lemma real_root_divide: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

233 
"0 < n \<Longrightarrow> root n (x / y) = root n x / root n y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

234 
by (simp add: divide_inverse real_root_mult real_root_inverse) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

235 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

236 
lemma real_root_power: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

237 
"0 < n \<Longrightarrow> root n (x ^ k) = root n x ^ k" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

238 
by (induct k, simp_all add: real_root_mult) 
22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

239 

23042
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

240 
lemma real_root_abs: "0 < n \<Longrightarrow> root n \<bar>x\<bar> = \<bar>root n x\<bar>" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

241 
by (simp add: abs_if real_root_minus) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

242 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

243 
text {* Continuity and derivatives *} 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

244 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

245 
lemma isCont_root_pos: 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

246 
assumes n: "0 < n" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

247 
assumes x: "0 < x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

248 
shows "isCont (root n) x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

249 
proof  
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

250 
have "isCont (root n) (root n x ^ n)" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

251 
proof (rule isCont_inverse_function [where f="\<lambda>a. a ^ n"]) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

252 
show "0 < root n x" using n x by simp 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

253 
show "\<forall>z. \<bar>z  root n x\<bar> \<le> root n x \<longrightarrow> root n (z ^ n) = z" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

254 
by (simp add: abs_le_iff real_root_power_cancel n) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

255 
show "\<forall>z. \<bar>z  root n x\<bar> \<le> root n x \<longrightarrow> isCont (\<lambda>a. a ^ n) z" 
23069
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
huffman
parents:
23049
diff
changeset

256 
by (simp add: isCont_power) 
23042
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

257 
qed 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

258 
thus ?thesis using n x by simp 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

259 
qed 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

260 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

261 
lemma isCont_root_neg: 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

262 
"\<lbrakk>0 < n; x < 0\<rbrakk> \<Longrightarrow> isCont (root n) x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

263 
apply (subgoal_tac "isCont (\<lambda>x.  root n ( x)) x") 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

264 
apply (simp add: real_root_minus) 
23069
cdfff0241c12
rename lemmas LIM_ident, isCont_ident, DERIV_ident
huffman
parents:
23049
diff
changeset

265 
apply (rule isCont_o2 [OF isCont_minus [OF isCont_ident]]) 
23042
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

266 
apply (simp add: isCont_minus isCont_root_pos) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

267 
done 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

268 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

269 
lemma isCont_root_zero: 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

270 
"0 < n \<Longrightarrow> isCont (root n) 0" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

271 
unfolding isCont_def 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

272 
apply (rule LIM_I) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

273 
apply (rule_tac x="r ^ n" in exI, safe) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

274 
apply (simp add: zero_less_power) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

275 
apply (simp add: real_root_abs [symmetric]) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

276 
apply (rule_tac n="n" in power_less_imp_less_base, simp_all) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

277 
done 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

278 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

279 
lemma isCont_real_root: "0 < n \<Longrightarrow> isCont (root n) x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

280 
apply (rule_tac x=x and y=0 in linorder_cases) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

281 
apply (simp_all add: isCont_root_pos isCont_root_neg isCont_root_zero) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

282 
done 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

283 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

284 
lemma DERIV_real_root: 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

285 
assumes n: "0 < n" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

286 
assumes x: "0 < x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

287 
shows "DERIV (root n) x :> inverse (real n * root n x ^ (n  Suc 0))" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

288 
proof (rule DERIV_inverse_function) 
23044  289 
show "0 < x" using x . 
290 
show "x < x + 1" by simp 

291 
show "\<forall>y. 0 < y \<and> y < x + 1 \<longrightarrow> root n y ^ n = y" 

23042
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

292 
using n by simp 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

293 
show "DERIV (\<lambda>x. x ^ n) (root n x) :> real n * root n x ^ (n  Suc 0)" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

294 
by (rule DERIV_pow) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

295 
show "real n * root n x ^ (n  Suc 0) \<noteq> 0" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

296 
using n x by simp 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

297 
show "isCont (root n) x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

298 
by (rule isCont_real_root) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

299 
qed 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

300 

23046  301 
lemma DERIV_odd_real_root: 
302 
assumes n: "odd n" 

303 
assumes x: "x \<noteq> 0" 

304 
shows "DERIV (root n) x :> inverse (real n * root n x ^ (n  Suc 0))" 

305 
proof (rule DERIV_inverse_function) 

306 
show "x  1 < x" by simp 

307 
show "x < x + 1" by simp 

308 
show "\<forall>y. x  1 < y \<and> y < x + 1 \<longrightarrow> root n y ^ n = y" 

309 
using n by (simp add: odd_real_root_pow) 

310 
show "DERIV (\<lambda>x. x ^ n) (root n x) :> real n * root n x ^ (n  Suc 0)" 

311 
by (rule DERIV_pow) 

312 
show "real n * root n x ^ (n  Suc 0) \<noteq> 0" 

313 
using odd_pos [OF n] x by simp 

314 
show "isCont (root n) x" 

315 
using odd_pos [OF n] by (rule isCont_real_root) 

316 
qed 

317 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

318 
subsection {* Square Root *} 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

319 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

320 
definition 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

321 
sqrt :: "real \<Rightarrow> real" where 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

322 
"sqrt = root 2" 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

323 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

324 
lemma pos2: "0 < (2::nat)" by simp 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

325 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

326 
lemma real_sqrt_unique: "\<lbrakk>y\<twosuperior> = x; 0 \<le> y\<rbrakk> \<Longrightarrow> sqrt x = y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

327 
unfolding sqrt_def by (rule real_root_pos_unique [OF pos2]) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

328 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

329 
lemma real_sqrt_abs [simp]: "sqrt (x\<twosuperior>) = \<bar>x\<bar>" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

330 
apply (rule real_sqrt_unique) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

331 
apply (rule power2_abs) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

332 
apply (rule abs_ge_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

333 
done 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

334 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

335 
lemma real_sqrt_pow2 [simp]: "0 \<le> x \<Longrightarrow> (sqrt x)\<twosuperior> = x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

336 
unfolding sqrt_def by (rule real_root_pow_pos2 [OF pos2]) 
22856  337 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

338 
lemma real_sqrt_pow2_iff [simp]: "((sqrt x)\<twosuperior> = x) = (0 \<le> x)" 
22856  339 
apply (rule iffI) 
340 
apply (erule subst) 

341 
apply (rule zero_le_power2) 

342 
apply (erule real_sqrt_pow2) 

20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

343 
done 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

344 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

345 
lemma real_sqrt_zero [simp]: "sqrt 0 = 0" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

346 
unfolding sqrt_def by (rule real_root_zero) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

347 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

348 
lemma real_sqrt_one [simp]: "sqrt 1 = 1" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

349 
unfolding sqrt_def by (rule real_root_one [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

350 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

351 
lemma real_sqrt_minus: "sqrt ( x) =  sqrt x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

352 
unfolding sqrt_def by (rule real_root_minus [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

353 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

354 
lemma real_sqrt_mult: "sqrt (x * y) = sqrt x * sqrt y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

355 
unfolding sqrt_def by (rule real_root_mult [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

356 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

357 
lemma real_sqrt_inverse: "sqrt (inverse x) = inverse (sqrt x)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

358 
unfolding sqrt_def by (rule real_root_inverse [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

359 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

360 
lemma real_sqrt_divide: "sqrt (x / y) = sqrt x / sqrt y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

361 
unfolding sqrt_def by (rule real_root_divide [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

362 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

363 
lemma real_sqrt_power: "sqrt (x ^ k) = sqrt x ^ k" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

364 
unfolding sqrt_def by (rule real_root_power [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

365 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

366 
lemma real_sqrt_gt_zero: "0 < x \<Longrightarrow> 0 < sqrt x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

367 
unfolding sqrt_def by (rule real_root_gt_zero [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

368 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

369 
lemma real_sqrt_ge_zero: "0 \<le> x \<Longrightarrow> 0 \<le> sqrt x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

370 
unfolding sqrt_def by (rule real_root_ge_zero [OF pos2]) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

371 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

372 
lemma real_sqrt_less_mono: "x < y \<Longrightarrow> sqrt x < sqrt y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

373 
unfolding sqrt_def by (rule real_root_less_mono [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

374 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

375 
lemma real_sqrt_le_mono: "x \<le> y \<Longrightarrow> sqrt x \<le> sqrt y" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

376 
unfolding sqrt_def by (rule real_root_le_mono [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

377 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

378 
lemma real_sqrt_less_iff [simp]: "(sqrt x < sqrt y) = (x < y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

379 
unfolding sqrt_def by (rule real_root_less_iff [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

380 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

381 
lemma real_sqrt_le_iff [simp]: "(sqrt x \<le> sqrt y) = (x \<le> y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

382 
unfolding sqrt_def by (rule real_root_le_iff [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

383 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

384 
lemma real_sqrt_eq_iff [simp]: "(sqrt x = sqrt y) = (x = y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

385 
unfolding sqrt_def by (rule real_root_eq_iff [OF pos2]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

386 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

387 
lemmas real_sqrt_gt_0_iff [simp] = real_sqrt_less_iff [where x=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

388 
lemmas real_sqrt_lt_0_iff [simp] = real_sqrt_less_iff [where y=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

389 
lemmas real_sqrt_ge_0_iff [simp] = real_sqrt_le_iff [where x=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

390 
lemmas real_sqrt_le_0_iff [simp] = real_sqrt_le_iff [where y=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

391 
lemmas real_sqrt_eq_0_iff [simp] = real_sqrt_eq_iff [where y=0, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

392 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

393 
lemmas real_sqrt_gt_1_iff [simp] = real_sqrt_less_iff [where x=1, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

394 
lemmas real_sqrt_lt_1_iff [simp] = real_sqrt_less_iff [where y=1, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

395 
lemmas real_sqrt_ge_1_iff [simp] = real_sqrt_le_iff [where x=1, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

396 
lemmas real_sqrt_le_1_iff [simp] = real_sqrt_le_iff [where y=1, simplified] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

397 
lemmas real_sqrt_eq_1_iff [simp] = real_sqrt_eq_iff [where y=1, simplified] 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

398 

23042
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

399 
lemma isCont_real_sqrt: "isCont sqrt x" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

400 
unfolding sqrt_def by (rule isCont_real_root [OF pos2]) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

401 

492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

402 
lemma DERIV_real_sqrt: 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

403 
"0 < x \<Longrightarrow> DERIV sqrt x :> inverse (sqrt x) / 2" 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

404 
unfolding sqrt_def by (rule DERIV_real_root [OF pos2, simplified]) 
492514b39956
add lemmas about continuity and derivatives of roots
huffman
parents:
23009
diff
changeset

405 

20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

406 
lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

407 
apply auto 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

408 
apply (cut_tac x = x and y = 0 in linorder_less_linear) 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

409 
apply (simp add: zero_less_mult_iff) 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

410 
done 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

411 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

412 
lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \<bar>x\<bar>" 
22856  413 
apply (subst power2_eq_square [symmetric]) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

414 
apply (rule real_sqrt_abs) 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

415 
done 
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

416 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

417 
lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)\<twosuperior>" 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

418 
by simp (* TODO: delete *) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

419 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

420 
lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x \<noteq> 0" 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

421 
by simp (* TODO: delete *) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

422 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

423 
lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x" 
22856  424 
by (simp add: power_inverse [symmetric]) 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

425 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

426 
lemma real_sqrt_eq_zero_cancel: "[ 0 \<le> x; sqrt(x) = 0] ==> x = 0" 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

427 
by simp 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

428 

fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

429 
lemma real_sqrt_ge_one: "1 \<le> x ==> 1 \<le> sqrt x" 
22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

430 
by simp 
20687
fedb901be392
move root and sqrt stuff from Transcendental to NthRoot
huffman
parents:
20515
diff
changeset

431 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

432 
lemma real_sqrt_two_gt_zero [simp]: "0 < sqrt 2" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

433 
by simp 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

434 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

435 
lemma real_sqrt_two_ge_zero [simp]: "0 \<le> sqrt 2" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

436 
by simp 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

437 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

438 
lemma real_sqrt_two_gt_one [simp]: "1 < sqrt 2" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

439 
by simp 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

440 

22443  441 
lemma sqrt_divide_self_eq: 
442 
assumes nneg: "0 \<le> x" 

443 
shows "sqrt x / x = inverse (sqrt x)" 

444 
proof cases 

445 
assume "x=0" thus ?thesis by simp 

446 
next 

447 
assume nz: "x\<noteq>0" 

448 
hence pos: "0<x" using nneg by arith 

449 
show ?thesis 

450 
proof (rule right_inverse_eq [THEN iffD1, THEN sym]) 

451 
show "sqrt x / x \<noteq> 0" by (simp add: divide_inverse nneg nz) 

452 
show "inverse (sqrt x) / (sqrt x / x) = 1" 

453 
by (simp add: divide_inverse mult_assoc [symmetric] 

454 
power2_eq_square [symmetric] real_inv_sqrt_pow2 pos nz) 

455 
qed 

456 
qed 

457 

22721
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

458 
lemma real_divide_square_eq [simp]: "(((r::real) * a) / (r * r)) = a / r" 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

459 
apply (simp add: divide_inverse) 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

460 
apply (case_tac "r=0") 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

461 
apply (auto simp add: mult_ac) 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

462 
done 
d9be18bd7a28
moved root and sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
22630
diff
changeset

463 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

464 
lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

465 
by (simp add: divide_less_eq mult_compare_simps) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

466 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

467 
lemma four_x_squared: 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

468 
fixes x::real 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

469 
shows "4 * x\<twosuperior> = (2 * x)\<twosuperior>" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

470 
by (simp add: power2_eq_square) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

471 

22856  472 
subsection {* Square Root of Sum of Squares *} 
473 

474 
lemma real_sqrt_mult_self_sum_ge_zero [simp]: "0 \<le> sqrt(x*x + y*y)" 

22968  475 
by (rule real_sqrt_ge_zero [OF sum_squares_ge_zero]) 
22856  476 

477 
lemma real_sqrt_sum_squares_ge_zero [simp]: "0 \<le> sqrt (x\<twosuperior> + y\<twosuperior>)" 

22961  478 
by simp 
22856  479 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

480 
declare real_sqrt_sum_squares_ge_zero [THEN abs_of_nonneg, simp] 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

481 

22856  482 
lemma real_sqrt_sum_squares_mult_ge_zero [simp]: 
483 
"0 \<le> sqrt ((x\<twosuperior> + y\<twosuperior>)*(xa\<twosuperior> + ya\<twosuperior>))" 

484 
by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff) 

485 

486 
lemma real_sqrt_sum_squares_mult_squared_eq [simp]: 

487 
"sqrt ((x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)) ^ 2 = (x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)" 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

488 
by (auto simp add: zero_le_mult_iff) 
22856  489 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

490 
lemma real_sqrt_sum_squares_eq_cancel: "sqrt (x\<twosuperior> + y\<twosuperior>) = x \<Longrightarrow> y = 0" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

491 
by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, simp) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

492 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

493 
lemma real_sqrt_sum_squares_eq_cancel2: "sqrt (x\<twosuperior> + y\<twosuperior>) = y \<Longrightarrow> x = 0" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

494 
by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, simp) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

495 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

496 
lemma real_sqrt_sum_squares_ge1 [simp]: "x \<le> sqrt (x\<twosuperior> + y\<twosuperior>)" 
22856  497 
by (rule power2_le_imp_le, simp_all) 
498 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

499 
lemma real_sqrt_sum_squares_ge2 [simp]: "y \<le> sqrt (x\<twosuperior> + y\<twosuperior>)" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

500 
by (rule power2_le_imp_le, simp_all) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

501 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

502 
lemma real_sqrt_ge_abs1 [simp]: "\<bar>x\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)" 
22856  503 
by (rule power2_le_imp_le, simp_all) 
504 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

505 
lemma real_sqrt_ge_abs2 [simp]: "\<bar>y\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

506 
by (rule power2_le_imp_le, simp_all) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

507 

11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

508 
lemma le_real_sqrt_sumsq [simp]: "x \<le> sqrt (x * x + y * y)" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

509 
by (simp add: power2_eq_square [symmetric]) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

510 

22858  511 
lemma power2_sum: 
512 
fixes x y :: "'a::{number_ring,recpower}" 

513 
shows "(x + y)\<twosuperior> = x\<twosuperior> + y\<twosuperior> + 2 * x * y" 

514 
by (simp add: left_distrib right_distrib power2_eq_square) 

515 

516 
lemma power2_diff: 

517 
fixes x y :: "'a::{number_ring,recpower}" 

518 
shows "(x  y)\<twosuperior> = x\<twosuperior> + y\<twosuperior>  2 * x * y" 

519 
by (simp add: left_diff_distrib right_diff_distrib power2_eq_square) 

520 

521 
lemma real_sqrt_sum_squares_triangle_ineq: 

522 
"sqrt ((a + c)\<twosuperior> + (b + d)\<twosuperior>) \<le> sqrt (a\<twosuperior> + b\<twosuperior>) + sqrt (c\<twosuperior> + d\<twosuperior>)" 

523 
apply (rule power2_le_imp_le, simp) 

524 
apply (simp add: power2_sum) 

525 
apply (simp only: mult_assoc right_distrib [symmetric]) 

526 
apply (rule mult_left_mono) 

527 
apply (rule power2_le_imp_le) 

528 
apply (simp add: power2_sum power_mult_distrib) 

529 
apply (simp add: ring_distrib) 

530 
apply (subgoal_tac "0 \<le> b\<twosuperior> * c\<twosuperior> + a\<twosuperior> * d\<twosuperior>  2 * (a * c) * (b * d)", simp) 

531 
apply (rule_tac b="(a * d  b * c)\<twosuperior>" in ord_le_eq_trans) 

532 
apply (rule zero_le_power2) 

533 
apply (simp add: power2_diff power_mult_distrib) 

534 
apply (simp add: mult_nonneg_nonneg) 

535 
apply simp 

536 
apply (simp add: add_increasing) 

537 
done 

538 

23122  539 
lemma real_sqrt_sum_squares_less: 
540 
"\<lbrakk>\<bar>x\<bar> < u / sqrt 2; \<bar>y\<bar> < u / sqrt 2\<rbrakk> \<Longrightarrow> sqrt (x\<twosuperior> + y\<twosuperior>) < u" 

541 
apply (rule power2_less_imp_less, simp) 

542 
apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) 

543 
apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) 

544 
apply (simp add: power_divide) 

545 
apply (drule order_le_less_trans [OF abs_ge_zero]) 

546 
apply (simp add: zero_less_divide_iff) 

547 
done 

548 

23049
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

549 
text{*Needed for the infinitely close relation over the nonstandard 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

550 
complex numbers*} 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

551 
lemma lemma_sqrt_hcomplex_capprox: 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

552 
"[ 0 < u; x < u/2; y < u/2; 0 \<le> x; 0 \<le> y ] ==> sqrt (x\<twosuperior> + y\<twosuperior>) < u" 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

553 
apply (rule_tac y = "u/sqrt 2" in order_le_less_trans) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

554 
apply (erule_tac [2] lemma_real_divide_sqrt_less) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

555 
apply (rule power2_le_imp_le) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

556 
apply (auto simp add: real_0_le_divide_iff power_divide) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

557 
apply (rule_tac t = "u\<twosuperior>" in real_sum_of_halves [THEN subst]) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

558 
apply (rule add_mono) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

559 
apply (auto simp add: four_x_squared simp del: realpow_Suc intro: power_mono) 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

560 
done 
11607c283074
moved sqrt lemmas from Transcendental.thy to NthRoot.thy
huffman
parents:
23047
diff
changeset

561 

22956
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

562 
text "Legacy theorem names:" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

563 
lemmas real_root_pos2 = real_root_power_cancel 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

564 
lemmas real_root_pos_pos = real_root_gt_zero [THEN order_less_imp_le] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

565 
lemmas real_root_pos_pos_le = real_root_ge_zero 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

566 
lemmas real_sqrt_mult_distrib = real_sqrt_mult 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

567 
lemmas real_sqrt_mult_distrib2 = real_sqrt_mult 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

568 
lemmas real_sqrt_eq_zero_cancel_iff = real_sqrt_eq_0_iff 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

569 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

570 
(* needed for CauchysMeanTheorem.het_base from AFP *) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

571 
lemma real_root_pos: "0 < x \<Longrightarrow> root (Suc n) (x ^ (Suc n)) = x" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

572 
by (rule real_root_power_cancel [OF zero_less_Suc order_less_imp_le]) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

573 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

574 
(* FIXME: the stronger version of real_root_less_iff 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

575 
breaks CauchysMeanTheorem.list_gmean_gt_iff from AFP. *) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

576 

617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

577 
declare real_root_less_iff [simp del] 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

578 
lemma real_root_less_iff_nonneg [simp]: 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

579 
"\<lbrakk>0 < n; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> (root n x < root n y) = (x < y)" 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

580 
by (rule real_root_less_iff) 
617140080e6a
define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents:
22943
diff
changeset

581 

14324  582 
end 