equal
deleted
inserted
replaced
1122 hide_fact (open) compute_lapprox_posrat |
1122 hide_fact (open) compute_lapprox_posrat |
1123 |
1123 |
1124 lift_definition rapprox_posrat :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> float" |
1124 lift_definition rapprox_posrat :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> float" |
1125 is "\<lambda>prec (x::nat) (y::nat). round_up (rat_precision prec x y) (x / y)" by simp |
1125 is "\<lambda>prec (x::nat) (y::nat). round_up (rat_precision prec x y) (x / y)" by simp |
1126 |
1126 |
1127 lemma compute_rapprox_posrat[code]: |
1127 context |
|
1128 notes divmod_int_mod_div[simp] |
|
1129 begin |
|
1130 |
|
1131 qualified lemma compute_rapprox_posrat[code]: |
1128 fixes prec x y |
1132 fixes prec x y |
1129 notes divmod_int_mod_div[simp] |
|
1130 defines "l \<equiv> rat_precision prec x y" |
1133 defines "l \<equiv> rat_precision prec x y" |
1131 shows "rapprox_posrat prec x y = (let |
1134 shows "rapprox_posrat prec x y = (let |
1132 l = l ; |
1135 l = l ; |
1133 X = if 0 \<le> l then (x * 2^nat l, y) else (x, y * 2^nat(-l)) ; |
1136 X = if 0 \<le> l then (x * 2^nat l, y) else (x, y * 2^nat(-l)) ; |
1134 (d, m) = divmod_int (fst X) (snd X) |
1137 (d, m) = divmod_int (fst X) (snd X) |
1161 l_def[symmetric, THEN meta_eq_to_obj_eq] |
1164 l_def[symmetric, THEN meta_eq_to_obj_eq] |
1162 by transfer |
1165 by transfer |
1163 (auto simp add: round_up_def ceil_divide_floor_conv floor_divide_eq_div [symmetric]) |
1166 (auto simp add: round_up_def ceil_divide_floor_conv floor_divide_eq_div [symmetric]) |
1164 qed |
1167 qed |
1165 qed |
1168 qed |
1166 hide_fact (open) compute_rapprox_posrat |
1169 |
|
1170 end |
1167 |
1171 |
1168 lemma rat_precision_pos: |
1172 lemma rat_precision_pos: |
1169 assumes "0 \<le> x" and "0 < y" and "2 * x < y" and "0 < n" |
1173 assumes "0 \<le> x" and "0 < y" and "2 * x < y" and "0 < n" |
1170 shows "rat_precision n (int x) (int y) > 0" |
1174 shows "rat_precision n (int x) (int y) > 0" |
1171 proof - |
1175 proof - |