# HG changeset patch # User haftmann # Date 1560501268 0 # Node ID e5cd5471c18a0c3b9ee6c5671aa573aa56f2f988 # Parent 408e15cbd2a60eee68dde9ecd1d039b2c415378a official fact collection sign_simps diff -r 408e15cbd2a6 -r e5cd5471c18a NEWS --- a/NEWS Fri Jun 14 08:34:28 2019 +0000 +++ b/NEWS Fri Jun 14 08:34:28 2019 +0000 @@ -18,6 +18,11 @@ Z2 (0 / 1): theory HOL/Library/Bit.thy has been renamed accordingly. INCOMPATIBILITY. +* Fact collection sign_simps contains only simplification rules +for products being less / greater / equal to zero; combine with +existing collections algebra_simps or field_simps to obtain +reasonable simplification. INCOMPATIBILITY. + New in Isabelle2019 (June 2019) ------------------------------- diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Analysis/Conformal_Mappings.thy --- a/src/HOL/Analysis/Conformal_Mappings.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Analysis/Conformal_Mappings.thy Fri Jun 14 08:34:28 2019 +0000 @@ -1878,9 +1878,9 @@ apply (simp add: power2_eq_square divide_simps C_def norm_mult) proof - have "norm z * (norm (deriv f 0) * (r - norm z - norm z)) \ norm z * (norm (deriv f 0) * (r - norm z) - norm (deriv f 0) * norm z)" - by (simp add: sign_simps) + by (simp add: algebra_simps) then show "(norm z * (r - norm z) - norm z * norm z) * norm (deriv f 0) \ norm (deriv f 0) * norm z * (r - norm z) - norm z * norm z * norm (deriv f 0)" - by (simp add: sign_simps) + by (simp add: algebra_simps) qed qed have sq201 [simp]: "0 < (1 - sqrt 2 / 2)" "(1 - sqrt 2 / 2) < 1" diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Decision_Procs/Approximation_Bounds.thy --- a/src/HOL/Decision_Procs/Approximation_Bounds.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Decision_Procs/Approximation_Bounds.thy Fri Jun 14 08:34:28 2019 +0000 @@ -1588,7 +1588,7 @@ by (cases "k = 0") (auto intro!: add_mono simp add: k [symmetric] uminus_add_conv_diff [symmetric] - simp del: float_of_numeral uminus_add_conv_diff) + simp del: uminus_add_conv_diff) hence "?lx \ x - k * (2 * pi) \ x - k * (2 * pi) \ ?ux" by (auto intro!: float_plus_down_le float_plus_up_le) note lx = this[THEN conjunct1] and ux = this[THEN conjunct2] diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Groups.thy --- a/src/HOL/Groups.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Groups.thy Fri Jun 14 08:34:28 2019 +0000 @@ -15,8 +15,9 @@ subsection \Dynamic facts\ named_theorems ac_simps "associativity and commutativity simplification rules" - and algebra_simps "algebra simplification rules" + and algebra_simps "algebra simplification rules for rings" and field_simps "algebra simplification rules for fields" + and sign_simps "algebra simplification rules for comparision with zero" text \ The rewrites accumulated in \algebra_simps\ deal with the classical @@ -32,6 +33,10 @@ can be proved to be non-zero (for equations) or positive/negative (for inequalities). Can be too aggressive and is therefore separate from the more benign \algebra_simps\. + + Lemmas \sign_simps\ is a first attempt to automate proofs + of positivity/negativity needed for \field_simps\. Have not added \sign_simps\ to \field_simps\ + because the former can lead to case explosions. \ diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Library/Float.thy --- a/src/HOL/Library/Float.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Library/Float.thy Fri Jun 14 08:34:28 2019 +0000 @@ -495,10 +495,10 @@ by (auto simp: mantissa_exponent sign_simps) lemma mantissa_nonneg_iff: "0 \ mantissa x \ 0 \ x" - by (auto simp: mantissa_exponent sign_simps zero_le_mult_iff) + by (auto simp: mantissa_exponent sign_simps) lemma mantissa_neg_iff: "0 > mantissa x \ 0 > x" - by (auto simp: mantissa_exponent sign_simps zero_le_mult_iff) + by (auto simp: mantissa_exponent sign_simps) lemma fixes m e :: int @@ -1788,8 +1788,8 @@ using truncate_down_uminus_eq[of p "x + y"] by transfer (simp add: plus_down_def plus_up_def ac_simps) -lemma mantissa_zero[simp]: "mantissa 0 = 0" - by (metis mantissa_0 zero_float.abs_eq) +lemma mantissa_zero: "mantissa 0 = 0" + by (fact mantissa_0) qualified lemma compute_float_less[code]: "a < b \ is_float_pos (float_plus_down 0 b (- a))" using truncate_down[of 0 "b - a"] truncate_down_pos[of "b - a" 0] @@ -1972,8 +1972,10 @@ from assms \0 < x\ have "log 2 x \ log 2 y" by auto with \\log 2 x\ \ \log 2 y\\ - have logless: "log 2 x < log 2 y" and flogless: "\log 2 x\ < \log 2 y\" - by (metis floor_less_cancel linorder_cases not_le)+ + have logless: "log 2 x < log 2 y" + by linarith + have flogless: "\log 2 x\ < \log 2 y\" + using \\log 2 x\ \ \log 2 y\\ \log 2 x \ log 2 y\ by linarith have "truncate_up prec x = real_of_int \x * 2 powr real_of_int (int prec - \log 2 x\ )\ * 2 powr - real_of_int (int prec - \log 2 x\)" using assms by (simp add: truncate_up_def round_up_def) diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Probability/ex/Koepf_Duermuth_Countermeasure.thy --- a/src/HOL/Probability/ex/Koepf_Duermuth_Countermeasure.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Probability/ex/Koepf_Duermuth_Countermeasure.thy Fri Jun 14 08:34:28 2019 +0000 @@ -80,9 +80,6 @@ qed qed simp -lemma zero_notin_Suc_image[simp]: "0 \ Suc ` A" - by auto - lemma prod_sum_distrib_lists: fixes P and S :: "'a set" and f :: "'a \ _::semiring_0" assumes "finite S" shows "(\ms\{ms. set ms \ S \ length ms = n \ (\ixi. P (Suc i)"] - by (simp add: sum.reindex split_conv sum_cartesian_product' + by (simp add: sum.reindex sum_cartesian_product' lessThan_Suc_eq_insert_0 prod.reindex sum_distrib_right[symmetric] sum_distrib_left[symmetric]) qed @@ -464,7 +461,7 @@ unfolding ce_OB_eq_ce_t by (rule mutual_information_eq_entropy_conditional_entropy simple_function_finite)+ also have "\ = \(t\OB) - \(t\OB | fst)" - unfolding entropy_chain_rule[symmetric, OF simple_function_finite simple_function_finite] sign_simps + unfolding entropy_chain_rule[symmetric, OF simple_function_finite simple_function_finite] algebra_simps by (subst entropy_commute) simp also have "\ \ \(t\OB)" using conditional_entropy_nonneg[of "t\OB" fst] by simp diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Rat.thy --- a/src/HOL/Rat.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Rat.thy Fri Jun 14 08:34:28 2019 +0000 @@ -529,14 +529,6 @@ end -text\Lemmas \sign_simps\ is a first attempt to automate proofs -of positivity/negativity needed for \field_simps\. Have not added \sign_simps\ to \field_simps\ because the former can lead to case -explosions.\ - -lemmas (in linordered_field) sign_simps [no_atp] = algebra_simps zero_less_mult_iff mult_less_0_iff -lemmas sign_simps [no_atp] = algebra_simps zero_less_mult_iff mult_less_0_iff - - instantiation rat :: distrib_lattice begin diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/Rings.thy --- a/src/HOL/Rings.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/Rings.thy Fri Jun 14 08:34:28 2019 +0000 @@ -16,8 +16,8 @@ subsection \Semirings and rings\ class semiring = ab_semigroup_add + semigroup_mult + - assumes distrib_right[algebra_simps]: "(a + b) * c = a * c + b * c" - assumes distrib_left[algebra_simps]: "a * (b + c) = a * b + a * c" + assumes distrib_right [algebra_simps]: "(a + b) * c = a * c + b * c" + assumes distrib_left [algebra_simps]: "a * (b + c) = a * b + a * c" begin text \For the \combine_numerals\ simproc\ @@ -2176,17 +2176,17 @@ by (simp add: neq_iff) qed -lemma zero_less_mult_iff: "0 < a * b \ 0 < a \ 0 < b \ a < 0 \ b < 0" +lemma zero_less_mult_iff [sign_simps]: "0 < a * b \ 0 < a \ 0 < b \ a < 0 \ b < 0" by (cases a 0 b 0 rule: linorder_cases[case_product linorder_cases]) (auto simp add: mult_neg_neg not_less le_less dest: zero_less_mult_pos zero_less_mult_pos2) -lemma zero_le_mult_iff: "0 \ a * b \ 0 \ a \ 0 \ b \ a \ 0 \ b \ 0" +lemma zero_le_mult_iff [sign_simps]: "0 \ a * b \ 0 \ a \ 0 \ b \ a \ 0 \ b \ 0" by (auto simp add: eq_commute [of 0] le_less not_less zero_less_mult_iff) -lemma mult_less_0_iff: "a * b < 0 \ 0 < a \ b < 0 \ a < 0 \ 0 < b" +lemma mult_less_0_iff [sign_simps]: "a * b < 0 \ 0 < a \ b < 0 \ a < 0 \ 0 < b" using zero_less_mult_iff [of "- a" b] by auto -lemma mult_le_0_iff: "a * b \ 0 \ 0 \ a \ b \ 0 \ a \ 0 \ 0 \ b" +lemma mult_le_0_iff [sign_simps]: "a * b \ 0 \ 0 \ a \ b \ 0 \ a \ 0 \ 0 \ b" using zero_le_mult_iff [of "- a" b] by auto text \ diff -r 408e15cbd2a6 -r e5cd5471c18a src/HOL/ex/Ballot.thy --- a/src/HOL/ex/Ballot.thy Fri Jun 14 08:34:28 2019 +0000 +++ b/src/HOL/ex/Ballot.thy Fri Jun 14 08:34:28 2019 +0000 @@ -223,13 +223,13 @@ have "Suc a * (a - Suc b) + (Suc a - b) * Suc b = (Suc a * a - Suc a * Suc b) + (Suc a * Suc b - Suc b * b)" - by (simp add: sign_simps) + by (simp add: algebra_simps) also have "\ = (Suc a * a + (Suc a * Suc b - Suc b * b)) - Suc a * Suc b" using \b by (intro add_diff_assoc2 mult_mono) auto also have "\ = (Suc a * a + Suc a * Suc b) - Suc b * b - Suc a * Suc b" using \b by (intro arg_cong2[where f="(-)"] add_diff_assoc mult_mono) auto also have "\ = (Suc a * Suc (a + b)) - (Suc b * Suc (a + b))" - by (simp add: sign_simps) + by (simp add: algebra_simps) finally have rearrange: "Suc a * (a - Suc b) + (Suc a - b) * Suc b = (Suc a - Suc b) * Suc (a + b)" unfolding diff_mult_distrib by simp