src/HOL/RealPow.thy
author huffman
Mon, 23 Feb 2009 16:25:52 -0800
changeset 30079 293b896b9c25
parent 29667 53103fc8ffa3
child 30082 43c5b7bfc791
permissions -rw-r--r--
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28952
15a4b2cf8c34 made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents: 28906
diff changeset
     1
(*  Title       : HOL/RealPow.thy
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot  
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
     3
    Copyright   : 1998  University of Cambridge
20634
45fe31e72391 add header
huffman
parents: 20517
diff changeset
     4
*)
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
     5
20634
45fe31e72391 add header
huffman
parents: 20517
diff changeset
     6
header {* Natural powers theory *}
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
     8
theory RealPow
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
     9
imports RealDef
28952
15a4b2cf8c34 made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents: 28906
diff changeset
    10
uses ("Tools/float_syntax.ML")
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
    11
begin
9435
c3a13a7d4424 lemmas [arith_split] = abs_split (*belongs to theory RealAbs*);
wenzelm
parents: 9013
diff changeset
    12
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    13
declare abs_mult_self [simp]
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    14
26565
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    15
instantiation real :: recpower
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    16
begin
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
    17
26565
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    18
primrec power_real where
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    19
  realpow_0:     "r ^ 0     = (1\<Colon>real)"
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    20
  | realpow_Suc: "r ^ Suc n = (r\<Colon>real) * r ^ n"
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
    21
26565
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    22
instance proof
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    23
  fix z :: real
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    24
  fix n :: nat
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    25
  show "z^0 = 1" by simp
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    26
  show "z^(Suc n) = z * (z^n)" by simp
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    27
qed
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    28
26565
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    29
end
522f45a8604e instantiation replacing primitive instance plus overloaded defs; realpow.simps now named power_real.simps
haftmann
parents: 25875
diff changeset
    30
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    31
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    32
lemma two_realpow_ge_one [simp]: "(1::real) \<le> 2 ^ n"
25875
536dfdc25e0a added simp attributes/ proofs fixed
nipkow
parents: 23477
diff changeset
    33
by simp
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    34
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    35
lemma two_realpow_gt [simp]: "real (n::nat) < 2 ^ n"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15229
diff changeset
    36
apply (induct "n")
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    37
apply (auto simp add: real_of_nat_Suc)
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14352
diff changeset
    38
apply (subst mult_2)
22962
4bb05ba38939 remove redundant lemmas
huffman
parents: 22958
diff changeset
    39
apply (rule add_less_le_mono)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    40
apply (auto simp add: two_realpow_ge_one)
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    41
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    42
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    43
lemma realpow_Suc_le_self: "[| 0 \<le> r; r \<le> (1::real) |] ==> r ^ Suc n \<le> r"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    44
by (insert power_decreasing [of 1 "Suc n" r], simp)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    45
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    46
lemma realpow_minus_mult [rule_format]:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    47
     "0 < n --> (x::real) ^ (n - 1) * x = x ^ n" 
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    48
apply (simp split add: nat_diff_split)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    49
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    50
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    51
lemma realpow_two_mult_inverse [simp]:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    52
     "r \<noteq> 0 ==> r * inverse r ^Suc (Suc 0) = inverse (r::real)"
23292
1c39f1bd1f53 deleted legacy lemmas
obua
parents: 23291
diff changeset
    53
by (simp add:  real_mult_assoc [symmetric])
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    54
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    55
lemma realpow_two_minus [simp]: "(-x)^Suc (Suc 0) = (x::real)^Suc (Suc 0)"
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    56
by simp
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    57
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    58
lemma realpow_two_diff:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    59
     "(x::real)^Suc (Suc 0) - y^Suc (Suc 0) = (x - y) * (x + y)"
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    60
apply (unfold real_diff_def)
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 28952
diff changeset
    61
apply (simp add: algebra_simps)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    62
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    63
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    64
lemma realpow_two_disj:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    65
     "((x::real)^Suc (Suc 0) = y^Suc (Suc 0)) = (x = y | x = -y)"
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    66
apply (cut_tac x = x and y = y in realpow_two_diff)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    67
apply (auto simp del: realpow_Suc)
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    68
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    69
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    70
lemma realpow_real_of_nat: "real (m::nat) ^ n = real (m ^ n)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15229
diff changeset
    71
apply (induct "n")
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    72
apply (auto simp add: real_of_nat_one real_of_nat_mult)
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    73
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    74
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
    75
lemma realpow_real_of_nat_two_pos [simp] : "0 < real (Suc (Suc 0) ^ n)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15229
diff changeset
    76
apply (induct "n")
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14304
diff changeset
    77
apply (auto simp add: real_of_nat_mult zero_less_mult_iff)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    78
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    79
22962
4bb05ba38939 remove redundant lemmas
huffman
parents: 22958
diff changeset
    80
(* used by AFP Integration theory *)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    81
lemma realpow_increasing:
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    82
     "[|(0::real) \<le> x; 0 \<le> y; x ^ Suc n \<le> y ^ Suc n|] ==> x \<le> y"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    83
  by (rule power_le_imp_le_base)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    84
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    85
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    86
subsection{*Literal Arithmetic Involving Powers, Type @{typ real}*}
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    87
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    88
lemma real_of_int_power: "real (x::int) ^ n = real (x ^ n)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15229
diff changeset
    89
apply (induct "n")
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14352
diff changeset
    90
apply (simp_all add: nat_mult_distrib)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    91
done
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    92
declare real_of_int_power [symmetric, simp]
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    93
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    94
lemma power_real_number_of:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
    95
     "(number_of v :: real) ^ n = real ((number_of v :: int) ^ n)"
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14352
diff changeset
    96
by (simp only: real_number_of [symmetric] real_of_int_power)
14265
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    97
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    98
declare power_real_number_of [of _ "number_of w", standard, simp]
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
    99
95b42e69436c HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents: 12018
diff changeset
   100
22967
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   101
subsection {* Properties of Squares *}
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   102
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   103
lemma sum_squares_ge_zero:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   104
  fixes x y :: "'a::ordered_ring_strict"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   105
  shows "0 \<le> x * x + y * y"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   106
by (intro add_nonneg_nonneg zero_le_square)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   107
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   108
lemma not_sum_squares_lt_zero:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   109
  fixes x y :: "'a::ordered_ring_strict"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   110
  shows "\<not> x * x + y * y < 0"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   111
by (simp add: linorder_not_less sum_squares_ge_zero)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   112
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   113
lemma sum_nonneg_eq_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   114
  fixes x y :: "'a::pordered_ab_group_add"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   115
  assumes x: "0 \<le> x" and y: "0 \<le> y"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   116
  shows "(x + y = 0) = (x = 0 \<and> y = 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   117
proof (auto)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   118
  from y have "x + 0 \<le> x + y" by (rule add_left_mono)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   119
  also assume "x + y = 0"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   120
  finally have "x \<le> 0" by simp
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   121
  thus "x = 0" using x by (rule order_antisym)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   122
next
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   123
  from x have "0 + y \<le> x + y" by (rule add_right_mono)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   124
  also assume "x + y = 0"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   125
  finally have "y \<le> 0" by simp
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   126
  thus "y = 0" using y by (rule order_antisym)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   127
qed
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   128
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   129
lemma sum_squares_eq_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   130
  fixes x y :: "'a::ordered_ring_strict"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   131
  shows "(x * x + y * y = 0) = (x = 0 \<and> y = 0)"
23096
423ad2fe9f76 *** empty log message ***
nipkow
parents: 22970
diff changeset
   132
by (simp add: sum_nonneg_eq_zero_iff)
22967
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   133
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   134
lemma sum_squares_le_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   135
  fixes x y :: "'a::ordered_ring_strict"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   136
  shows "(x * x + y * y \<le> 0) = (x = 0 \<and> y = 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   137
by (simp add: order_le_less not_sum_squares_lt_zero sum_squares_eq_zero_iff)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   138
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   139
lemma sum_squares_gt_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   140
  fixes x y :: "'a::ordered_ring_strict"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   141
  shows "(0 < x * x + y * y) = (x \<noteq> 0 \<or> y \<noteq> 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   142
by (simp add: order_less_le sum_squares_ge_zero sum_squares_eq_zero_iff)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   143
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   144
lemma sum_power2_ge_zero:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   145
  fixes x y :: "'a::{ordered_idom,recpower}"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   146
  shows "0 \<le> x\<twosuperior> + y\<twosuperior>"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   147
unfolding power2_eq_square by (rule sum_squares_ge_zero)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   148
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   149
lemma not_sum_power2_lt_zero:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   150
  fixes x y :: "'a::{ordered_idom,recpower}"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   151
  shows "\<not> x\<twosuperior> + y\<twosuperior> < 0"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   152
unfolding power2_eq_square by (rule not_sum_squares_lt_zero)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   153
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   154
lemma sum_power2_eq_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   155
  fixes x y :: "'a::{ordered_idom,recpower}"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   156
  shows "(x\<twosuperior> + y\<twosuperior> = 0) = (x = 0 \<and> y = 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   157
unfolding power2_eq_square by (rule sum_squares_eq_zero_iff)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   158
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   159
lemma sum_power2_le_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   160
  fixes x y :: "'a::{ordered_idom,recpower}"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   161
  shows "(x\<twosuperior> + y\<twosuperior> \<le> 0) = (x = 0 \<and> y = 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   162
unfolding power2_eq_square by (rule sum_squares_le_zero_iff)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   163
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   164
lemma sum_power2_gt_zero_iff:
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   165
  fixes x y :: "'a::{ordered_idom,recpower}"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   166
  shows "(0 < x\<twosuperior> + y\<twosuperior>) = (x \<noteq> 0 \<or> y \<noteq> 0)"
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   167
unfolding power2_eq_square by (rule sum_squares_gt_zero_iff)
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   168
0651b224528a added general sum-squares lemmas
huffman
parents: 22962
diff changeset
   169
22970
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   170
subsection{* Squares of Reals *}
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   171
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   172
lemma real_two_squares_add_zero_iff [simp]:
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   173
  "(x * x + y * y = 0) = ((x::real) = 0 \<and> y = 0)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   174
by (rule sum_squares_eq_zero_iff)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   175
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   176
lemma real_sum_squares_cancel: "x * x + y * y = 0 ==> x = (0::real)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   177
by simp
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   178
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   179
lemma real_sum_squares_cancel2: "x * x + y * y = 0 ==> y = (0::real)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   180
by simp
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   181
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   182
lemma real_mult_self_sum_ge_zero: "(0::real) \<le> x*x + y*y"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   183
by (rule sum_squares_ge_zero)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   184
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   185
lemma real_sum_squares_cancel_a: "x * x = -(y * y) ==> x = (0::real) & y=0"
22970
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   186
by (simp add: real_add_eq_0_iff [symmetric])
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   187
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   188
lemma real_squared_diff_one_factored: "x*x - (1::real) = (x + 1)*(x - 1)"
22970
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   189
by (simp add: left_distrib right_diff_distrib)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   190
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   191
lemma real_mult_is_one [simp]: "(x*x = (1::real)) = (x = 1 | x = - 1)"
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   192
apply auto
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   193
apply (drule right_minus_eq [THEN iffD2]) 
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   194
apply (auto simp add: real_squared_diff_one_factored)
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   195
done
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   196
22970
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   197
lemma real_sum_squares_not_zero: "x ~= 0 ==> x * x + y * y ~= (0::real)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   198
by simp
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   199
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   200
lemma real_sum_squares_not_zero2: "y ~= 0 ==> x * x + y * y ~= (0::real)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   201
by simp
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   202
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   203
lemma realpow_two_sum_zero_iff [simp]:
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   204
     "(x ^ 2 + y ^ 2 = (0::real)) = (x = 0 & y = 0)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   205
by (rule sum_power2_eq_zero_iff)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   206
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   207
lemma realpow_two_le_add_order [simp]: "(0::real) \<le> u ^ 2 + v ^ 2"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   208
by (rule sum_power2_ge_zero)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   209
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   210
lemma realpow_two_le_add_order2 [simp]: "(0::real) \<le> u ^ 2 + v ^ 2 + w ^ 2"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   211
by (intro add_nonneg_nonneg zero_le_power2)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   212
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   213
lemma real_sum_square_gt_zero: "x ~= 0 ==> (0::real) < x * x + y * y"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   214
by (simp add: sum_squares_gt_zero_iff)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   215
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   216
lemma real_sum_square_gt_zero2: "y ~= 0 ==> (0::real) < x * x + y * y"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   217
by (simp add: sum_squares_gt_zero_iff)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   218
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   219
lemma real_minus_mult_self_le [simp]: "-(u * u) \<le> (x * (x::real))"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   220
by (rule_tac j = 0 in real_le_trans, auto)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   221
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   222
lemma realpow_square_minus_le [simp]: "-(u ^ 2) \<le> (x::real) ^ 2"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   223
by (auto simp add: power2_eq_square)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   224
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   225
(* The following theorem is by Benjamin Porter *)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   226
lemma real_sq_order:
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   227
  fixes x::real
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   228
  assumes xgt0: "0 \<le> x" and ygt0: "0 \<le> y" and sq: "x^2 \<le> y^2"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   229
  shows "x \<le> y"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   230
proof -
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   231
  from sq have "x ^ Suc (Suc 0) \<le> y ^ Suc (Suc 0)"
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   232
    by (simp only: numeral_2_eq_2)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   233
  thus "x \<le> y" using ygt0
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   234
    by (rule power_le_imp_le_base)
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   235
qed
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   236
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   237
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   238
subsection {*Various Other Theorems*}
b5910e3dec4c move lemmas to RealPow.thy; tuned proofs
huffman
parents: 22967
diff changeset
   239
14304
cc0b4bbfbc43 minor tweaks
paulson
parents: 14288
diff changeset
   240
lemma real_le_add_half_cancel: "(x + y/2 \<le> (y::real)) = (x \<le> y /2)"
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   241
by auto
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   242
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   243
lemma real_minus_half_eq [simp]: "(x::real) - x/2 = x/2"
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   244
by auto
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   245
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   246
lemma real_mult_inverse_cancel:
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   247
     "[|(0::real) < x; 0 < x1; x1 * y < x * u |] 
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   248
      ==> inverse x * y < inverse x1 * u"
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   249
apply (rule_tac c=x in mult_less_imp_less_left) 
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   250
apply (auto simp add: real_mult_assoc [symmetric])
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14304
diff changeset
   251
apply (simp (no_asm) add: mult_ac)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   252
apply (rule_tac c=x1 in mult_less_imp_less_right) 
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14304
diff changeset
   253
apply (auto simp add: mult_ac)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   254
done
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   255
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   256
lemma real_mult_inverse_cancel2:
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   257
     "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1"
14334
6137d24eef79 tweaking of lemmas in RealDef, RealOrd
paulson
parents: 14304
diff changeset
   258
apply (auto dest: real_mult_inverse_cancel simp add: mult_ac)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   259
done
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   260
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   261
lemma inverse_real_of_nat_gt_zero [simp]: "0 < inverse (real (Suc n))"
20517
86343f2386a8 simplify some proofs, remove obsolete realpow_divide
huffman
parents: 19765
diff changeset
   262
by simp
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   263
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   264
lemma inverse_real_of_nat_ge_zero [simp]: "0 \<le> inverse (real (Suc n))"
20517
86343f2386a8 simplify some proofs, remove obsolete realpow_divide
huffman
parents: 19765
diff changeset
   265
by simp
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   266
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   267
lemma realpow_num_eq_if: "(m::real) ^ n = (if n=0 then 1 else m * m ^ (n - 1))"
14348
744c868ee0b7 Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents: 14334
diff changeset
   268
by (case_tac "n", auto)
14268
5cf13e80be0e Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents: 14265
diff changeset
   269
28906
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   270
subsection{* Float syntax *}
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   271
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   272
syntax "_Float" :: "float_const \<Rightarrow> 'a"    ("_")
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   273
28952
15a4b2cf8c34 made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents: 28906
diff changeset
   274
use "Tools/float_syntax.ML"
28906
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   275
setup FloatSyntax.setup
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   276
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   277
text{* Test: *}
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   278
lemma "123.456 = -111.111 + 200 + 30 + 4 + 5/10 + 6/100 + (7/1000::real)"
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   279
by simp
5f568bfc58d7 Floats for Real.
nipkow
parents: 26565
diff changeset
   280
7077
60b098bb8b8a heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
diff changeset
   281
end