955 f = Float 1 (s1 - s2) |
955 f = Float 1 (s1 - s2) |
956 in |
956 in |
957 f * l)" |
957 f * l)" |
958 |
958 |
959 lemma float_divl: "real (float_divl prec x y) \<le> real x / real y" |
959 lemma float_divl: "real (float_divl prec x y) \<le> real x / real y" |
960 proof - |
960 using lapprox_rat[of prec "mantissa x" "mantissa y"] |
961 from float_split[of x] obtain mx sx where x: "x = Float mx sx" by auto |
961 by (cases x y rule: float.exhaust[case_product float.exhaust]) |
962 from float_split[of y] obtain my sy where y: "y = Float my sy" by auto |
962 (simp split: split_if_asm |
963 have "real mx / real my \<le> (real mx * pow2 sx / (real my * pow2 sy)) / (pow2 (sx - sy))" |
963 add: real_of_float_simp pow2_diff field_simps le_divide_eq mult_less_0_iff zero_less_mult_iff) |
964 apply (case_tac "my = 0") |
|
965 apply simp |
|
966 apply (case_tac "my > 0") |
|
967 apply (subst pos_le_divide_eq) |
|
968 apply simp |
|
969 apply (subst pos_le_divide_eq) |
|
970 apply (simp add: mult_pos_pos) |
|
971 apply simp |
|
972 apply (subst pow2_add[symmetric]) |
|
973 apply simp |
|
974 apply (subgoal_tac "my < 0") |
|
975 apply auto |
|
976 apply (simp add: field_simps) |
|
977 apply (subst pow2_add[symmetric]) |
|
978 apply (simp add: field_simps) |
|
979 done |
|
980 then have "real (lapprox_rat prec mx my) \<le> (real mx * pow2 sx / (real my * pow2 sy)) / (pow2 (sx - sy))" |
|
981 by (rule order_trans[OF lapprox_rat]) |
|
982 then have "real (lapprox_rat prec mx my) * pow2 (sx - sy) \<le> real mx * pow2 sx / (real my * pow2 sy)" |
|
983 apply (subst pos_le_divide_eq[symmetric]) |
|
984 apply simp_all |
|
985 done |
|
986 then have "pow2 (sx - sy) * real (lapprox_rat prec mx my) \<le> real mx * pow2 sx / (real my * pow2 sy)" |
|
987 by (simp add: algebra_simps) |
|
988 then show ?thesis |
|
989 by (simp add: x y Let_def real_of_float_simp) |
|
990 qed |
|
991 |
964 |
992 lemma float_divl_lower_bound: assumes "0 \<le> x" and "0 < y" shows "0 \<le> float_divl prec x y" |
965 lemma float_divl_lower_bound: assumes "0 \<le> x" and "0 < y" shows "0 \<le> float_divl prec x y" |
993 proof (cases x, cases y) |
966 proof (cases x, cases y) |
994 fix xm xe ym ye :: int |
967 fix xm xe ym ye :: int |
995 assume x_eq: "x = Float xm xe" and y_eq: "y = Float ym ye" |
968 assume x_eq: "x = Float xm xe" and y_eq: "y = Float ym ye" |
1074 f = Float 1 (s1 - s2) |
1047 f = Float 1 (s1 - s2) |
1075 in |
1048 in |
1076 f * r)" |
1049 f * r)" |
1077 |
1050 |
1078 lemma float_divr: "real x / real y \<le> real (float_divr prec x y)" |
1051 lemma float_divr: "real x / real y \<le> real (float_divr prec x y)" |
1079 proof - |
1052 using rapprox_rat[of "mantissa x" "mantissa y" prec] |
1080 from float_split[of x] obtain mx sx where x: "x = Float mx sx" by auto |
1053 by (cases x y rule: float.exhaust[case_product float.exhaust]) |
1081 from float_split[of y] obtain my sy where y: "y = Float my sy" by auto |
1054 (simp split: split_if_asm |
1082 have "real mx / real my \<ge> (real mx * pow2 sx / (real my * pow2 sy)) / (pow2 (sx - sy))" |
1055 add: real_of_float_simp pow2_diff field_simps divide_le_eq mult_less_0_iff zero_less_mult_iff) |
1083 apply (case_tac "my = 0") |
|
1084 apply simp |
|
1085 apply (case_tac "my > 0") |
|
1086 apply auto |
|
1087 apply (subst pos_divide_le_eq) |
|
1088 apply (rule mult_pos_pos)+ |
|
1089 apply simp_all |
|
1090 apply (subst pow2_add[symmetric]) |
|
1091 apply simp |
|
1092 apply (subgoal_tac "my < 0") |
|
1093 apply auto |
|
1094 apply (simp add: field_simps) |
|
1095 apply (subst pow2_add[symmetric]) |
|
1096 apply (simp add: field_simps) |
|
1097 done |
|
1098 then have "real (rapprox_rat prec mx my) \<ge> (real mx * pow2 sx / (real my * pow2 sy)) / (pow2 (sx - sy))" |
|
1099 by (rule order_trans[OF _ rapprox_rat]) |
|
1100 then have "real (rapprox_rat prec mx my) * pow2 (sx - sy) \<ge> real mx * pow2 sx / (real my * pow2 sy)" |
|
1101 apply (subst pos_divide_le_eq[symmetric]) |
|
1102 apply simp_all |
|
1103 done |
|
1104 then show ?thesis |
|
1105 by (simp add: x y Let_def algebra_simps real_of_float_simp) |
|
1106 qed |
|
1107 |
1056 |
1108 lemma float_divr_pos_less1_lower_bound: assumes "0 < x" and "x < 1" shows "1 \<le> float_divr prec 1 x" |
1057 lemma float_divr_pos_less1_lower_bound: assumes "0 < x" and "x < 1" shows "1 \<le> float_divr prec 1 x" |
1109 proof - |
1058 proof - |
1110 have "1 \<le> 1 / real x" using `0 < x` and `x < 1` unfolding less_float_def by auto |
1059 have "1 \<le> 1 / real x" using `0 < x` and `x < 1` unfolding less_float_def by auto |
1111 also have "\<dots> \<le> real (float_divr prec 1 x)" using float_divr[where x=1 and y=x] by auto |
1060 also have "\<dots> \<le> real (float_divr prec 1 x)" using float_divr[where x=1 and y=x] by auto |