src/HOL/Library/Euclidean_Space.thy
changeset 31445 c8a474a919a7
parent 31417 c12b25b7f015
child 31492 5400beeddb55
equal deleted inserted replaced
31440:ee1d5bec4ce3 31445:c8a474a919a7
  1058 qed
  1058 qed
  1059 
  1059 
  1060 
  1060 
  1061 subsection{* General linear decision procedure for normed spaces. *}
  1061 subsection{* General linear decision procedure for normed spaces. *}
  1062 
  1062 
  1063 lemma norm_cmul_rule_thm: "b >= norm(x) ==> \<bar>c\<bar> * b >= norm(c *s x)"
  1063 lemma norm_cmul_rule_thm:
  1064   apply (clarsimp simp add: norm_mul)
  1064   fixes x :: "'a::real_normed_vector"
  1065   apply (rule mult_mono1)
  1065   shows "b >= norm(x) ==> \<bar>c\<bar> * b >= norm(scaleR c x)"
  1066   apply simp_all
  1066   unfolding norm_scaleR
       
  1067   apply (erule mult_mono1)
       
  1068   apply simp
  1067   done
  1069   done
  1068 
  1070 
  1069   (* FIXME: Move all these theorems into the ML code using lemma antiquotation *)
  1071   (* FIXME: Move all these theorems into the ML code using lemma antiquotation *)
  1070 lemma norm_add_rule_thm: "b1 >= norm(x1 :: real ^'n::finite) \<Longrightarrow> b2 >= norm(x2) ==> b1 + b2 >= norm(x1 + x2)"
  1072 lemma norm_add_rule_thm:
  1071   apply (rule norm_triangle_le) by simp
  1073   fixes x1 x2 :: "'a::real_normed_vector"
       
  1074   shows "norm x1 \<le> b1 \<Longrightarrow> norm x2 \<le> b2 \<Longrightarrow> norm (x1 + x2) \<le> b1 + b2"
       
  1075   by (rule order_trans [OF norm_triangle_ineq add_mono])
  1072 
  1076 
  1073 lemma ge_iff_diff_ge_0: "(a::'a::ordered_ring) \<ge> b == a - b \<ge> 0"
  1077 lemma ge_iff_diff_ge_0: "(a::'a::ordered_ring) \<ge> b == a - b \<ge> 0"
  1074   by (simp add: ring_simps)
  1078   by (simp add: ring_simps)
  1075 
  1079 
  1076 lemma pth_1: "(x::real^'n) == 1 *s x" by (simp only: vector_smult_lid)
  1080 lemma pth_1:
  1077 lemma pth_2: "x - (y::real^'n) == x + -y" by (atomize (full)) simp
  1081   fixes x :: "'a::real_normed_vector"
  1078 lemma pth_3: "(-x::real^'n) == -1 *s x" by vector
  1082   shows "x == scaleR 1 x" by simp
  1079 lemma pth_4: "0 *s (x::real^'n) == 0" "c *s 0 = (0::real ^ 'n)" by vector+
  1083 
  1080 lemma pth_5: "c *s (d *s x) == (c * d) *s (x::real ^ 'n)" by (atomize (full)) vector
  1084 lemma pth_2:
  1081 lemma pth_6: "(c::real) *s (x + y) == c *s x + c *s y" by (atomize (full)) (vector ring_simps)
  1085   fixes x :: "'a::real_normed_vector"
  1082 lemma pth_7: "0 + x == (x::real^'n)" "x + 0 == x" by simp_all
  1086   shows "x - y == x + -y" by (atomize (full)) simp
  1083 lemma pth_8: "(c::real) *s x + d *s x == (c + d) *s x" by (atomize (full)) (vector ring_simps)
  1087 
  1084 lemma pth_9: "((c::real) *s x + z) + d *s x == (c + d) *s x + z"
  1088 lemma pth_3:
  1085   "c *s x + (d *s x + z) == (c + d) *s x + z"
  1089   fixes x :: "'a::real_normed_vector"
  1086   "(c *s x + w) + (d *s x + z) == (c + d) *s x + (w + z)" by ((atomize (full)), vector ring_simps)+
  1090   shows "- x == scaleR (-1) x" by simp
  1087 lemma pth_a: "(0::real) *s x + y == y" by (atomize (full)) vector
  1091 
  1088 lemma pth_b: "(c::real) *s x + d *s y == c *s x + d *s y"
  1092 lemma pth_4:
  1089   "(c *s x + z) + d *s y == c *s x + (z + d *s y)"
  1093   fixes x :: "'a::real_normed_vector"
  1090   "c *s x + (d *s y + z) == c *s x + (d *s y + z)"
  1094   shows "scaleR 0 x == 0" and "scaleR c 0 = (0::'a)" by simp_all
  1091   "(c *s x + w) + (d *s y + z) == c *s x + (w + (d *s y + z))"
  1095 
  1092   by ((atomize (full)), vector)+
  1096 lemma pth_5:
  1093 lemma pth_c: "(c::real) *s x + d *s y == d *s y + c *s x"
  1097   fixes x :: "'a::real_normed_vector"
  1094   "(c *s x + z) + d *s y == d *s y + (c *s x + z)"
  1098   shows "scaleR c (scaleR d x) == scaleR (c * d) x" by simp
  1095   "c *s x + (d *s y + z) == d *s y + (c *s x + z)"
  1099 
  1096   "(c *s x + w) + (d *s y + z) == d *s y + ((c *s x + w) + z)" by ((atomize (full)), vector)+
  1100 lemma pth_6:
  1097 lemma pth_d: "x + (0::real ^'n) == x" by (atomize (full)) vector
  1101   fixes x :: "'a::real_normed_vector"
  1098 
  1102   shows "scaleR c (x + y) == scaleR c x + scaleR c y"
  1099 lemma norm_imp_pos_and_ge: "norm (x::real ^ _) == n \<Longrightarrow> norm x \<ge> 0 \<and> n \<ge> norm x"
  1103   by (simp add: scaleR_right_distrib)
  1100   by (atomize) (auto simp add: norm_ge_zero)
  1104 
       
  1105 lemma pth_7:
       
  1106   fixes x :: "'a::real_normed_vector"
       
  1107   shows "0 + x == x" and "x + 0 == x" by simp_all
       
  1108 
       
  1109 lemma pth_8:
       
  1110   fixes x :: "'a::real_normed_vector"
       
  1111   shows "scaleR c x + scaleR d x == scaleR (c + d) x"
       
  1112   by (simp add: scaleR_left_distrib)
       
  1113 
       
  1114 lemma pth_9:
       
  1115   fixes x :: "'a::real_normed_vector" shows
       
  1116   "(scaleR c x + z) + scaleR d x == scaleR (c + d) x + z"
       
  1117   "scaleR c x + (scaleR d x + z) == scaleR (c + d) x + z"
       
  1118   "(scaleR c x + w) + (scaleR d x + z) == scaleR (c + d) x + (w + z)"
       
  1119   by (simp_all add: algebra_simps)
       
  1120 
       
  1121 lemma pth_a:
       
  1122   fixes x :: "'a::real_normed_vector"
       
  1123   shows "scaleR 0 x + y == y" by simp
       
  1124 
       
  1125 lemma pth_b:
       
  1126   fixes x :: "'a::real_normed_vector" shows
       
  1127   "scaleR c x + scaleR d y == scaleR c x + scaleR d y"
       
  1128   "(scaleR c x + z) + scaleR d y == scaleR c x + (z + scaleR d y)"
       
  1129   "scaleR c x + (scaleR d y + z) == scaleR c x + (scaleR d y + z)"
       
  1130   "(scaleR c x + w) + (scaleR d y + z) == scaleR c x + (w + (scaleR d y + z))"
       
  1131   by (simp_all add: algebra_simps)
       
  1132 
       
  1133 lemma pth_c:
       
  1134   fixes x :: "'a::real_normed_vector" shows
       
  1135   "scaleR c x + scaleR d y == scaleR d y + scaleR c x"
       
  1136   "(scaleR c x + z) + scaleR d y == scaleR d y + (scaleR c x + z)"
       
  1137   "scaleR c x + (scaleR d y + z) == scaleR d y + (scaleR c x + z)"
       
  1138   "(scaleR c x + w) + (scaleR d y + z) == scaleR d y + ((scaleR c x + w) + z)"
       
  1139   by (simp_all add: algebra_simps)
       
  1140 
       
  1141 lemma pth_d:
       
  1142   fixes x :: "'a::real_normed_vector"
       
  1143   shows "x + 0 == x" by simp
       
  1144 
       
  1145 lemma norm_imp_pos_and_ge:
       
  1146   fixes x :: "'a::real_normed_vector"
       
  1147   shows "norm x == n \<Longrightarrow> norm x \<ge> 0 \<and> n \<ge> norm x"
       
  1148   by atomize auto
  1101 
  1149 
  1102 lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith
  1150 lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith
  1103 
  1151 
  1104 lemma norm_pths:
  1152 lemma norm_pths:
  1105   "(x::real ^'n::finite) = y \<longleftrightarrow> norm (x - y) \<le> 0"
  1153   fixes x :: "'a::real_normed_vector" shows
       
  1154   "x = y \<longleftrightarrow> norm (x - y) \<le> 0"
  1106   "x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)"
  1155   "x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)"
  1107   using norm_ge_zero[of "x - y"] by auto
  1156   using norm_ge_zero[of "x - y"] by auto
  1108 
  1157 
  1109 lemma vector_dist_norm:
  1158 lemma vector_dist_norm:
  1110   fixes x y :: "real ^ _"
  1159   fixes x :: "'a::real_normed_vector"
  1111   shows "dist x y = norm (x - y)"
  1160   shows "dist x y = norm (x - y)"
  1112   by (rule dist_norm)
  1161   by (rule dist_norm)
  1113 
  1162 
  1114 use "normarith.ML"
  1163 use "normarith.ML"
  1115 
  1164 
  1116 method_setup norm = {* Scan.succeed (SIMPLE_METHOD' o NormArith.norm_arith_tac)
  1165 method_setup norm = {* Scan.succeed (SIMPLE_METHOD' o NormArith.norm_arith_tac)
  1117 *} "Proves simple linear statements about vector norms"
  1166 *} "Proves simple linear statements about vector norms"
  1118 
       
  1119 
  1167 
  1120 
  1168 
  1121 text{* Hence more metric properties. *}
  1169 text{* Hence more metric properties. *}
  1122 
  1170 
  1123 lemma dist_triangle_alt:
  1171 lemma dist_triangle_alt:
  1156 by (rule dist_triangle_half_l, simp_all add: dist_commute)
  1204 by (rule dist_triangle_half_l, simp_all add: dist_commute)
  1157 
  1205 
  1158 lemma dist_triangle_add:
  1206 lemma dist_triangle_add:
  1159   fixes x y x' y' :: "'a::real_normed_vector"
  1207   fixes x y x' y' :: "'a::real_normed_vector"
  1160   shows "dist (x + y) (x' + y') <= dist x x' + dist y y'"
  1208   shows "dist (x + y) (x' + y') <= dist x x' + dist y y'"
  1161 unfolding dist_norm by (rule norm_diff_triangle_ineq)
  1209   by norm
  1162 
  1210 
  1163 lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
  1211 lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
  1164   unfolding dist_norm vector_ssub_ldistrib[symmetric] norm_mul ..
  1212   unfolding dist_norm vector_ssub_ldistrib[symmetric] norm_mul ..
  1165 
  1213 
  1166 lemma dist_triangle_add_half:
  1214 lemma dist_triangle_add_half:
  1167   fixes x x' y y' :: "'a::real_normed_vector"
  1215   fixes x x' y y' :: "'a::real_normed_vector"
  1168   shows "dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 \<Longrightarrow> dist(x + y) (x' + y') < e"
  1216   shows "dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 \<Longrightarrow> dist(x + y) (x' + y') < e"
  1169 by (rule le_less_trans [OF dist_triangle_add], simp)
  1217   by norm
  1170 
  1218 
  1171 lemma setsum_component [simp]:
  1219 lemma setsum_component [simp]:
  1172   fixes f:: " 'a \<Rightarrow> ('b::comm_monoid_add) ^'n"
  1220   fixes f:: " 'a \<Rightarrow> ('b::comm_monoid_add) ^'n"
  1173   shows "(setsum f S)$i = setsum (\<lambda>x. (f x)$i) S"
  1221   shows "(setsum f S)$i = setsum (\<lambda>x. (f x)$i) S"
  1174   by (cases "finite S", induct S set: finite, simp_all)
  1222   by (cases "finite S", induct S set: finite, simp_all)