# HG changeset patch # User hoelzl # Date 1455885650 -3600 # Node ID 85ed00c1fe7c94571194be4bd56d4da28d9c1f2e # Parent ace69956d01852f7d5992a97851473d2f96eec9b generalize more theorems to support enat and ennreal diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Binomial.thy --- a/src/HOL/Binomial.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Binomial.thy Fri Feb 19 13:40:50 2016 +0100 @@ -28,7 +28,7 @@ lemma of_nat_fact [simp]: "of_nat (fact n) = fact n" by (induct n) (auto simp add: algebra_simps of_nat_mult) - + lemma of_int_fact [simp]: "of_int (fact n) = fact n" proof - @@ -56,22 +56,22 @@ context assumes "SORT_CONSTRAINT('a::linordered_semidom)" begin - + lemma fact_mono: "m \ n \ fact m \ (fact n :: 'a)" by (metis of_nat_fact of_nat_le_iff fact_mono_nat) - + lemma fact_ge_1 [simp]: "fact n \ (1 :: 'a)" by (metis le0 fact.simps(1) fact_mono) - + lemma fact_gt_zero [simp]: "fact n > (0 :: 'a)" using fact_ge_1 less_le_trans zero_less_one by blast - + lemma fact_ge_zero [simp]: "fact n \ (0 :: 'a)" by (simp add: less_imp_le) lemma fact_not_neg [simp]: "~ (fact n < (0 :: 'a))" by (simp add: not_less_iff_gr_or_eq) - + lemma fact_le_power: "fact n \ (of_nat (n^n) ::'a)" proof (induct n) @@ -86,7 +86,7 @@ by (metis of_nat_mult order_refl power_Suc) finally show ?case . qed simp - + end text\Note that @{term "fact 0 = fact 1"}\ @@ -100,7 +100,7 @@ lemma fact_ge_Suc_0_nat [simp]: "fact n \ Suc 0" by (metis One_nat_def fact_ge_1) -lemma dvd_fact: +lemma dvd_fact: shows "1 \ m \ m \ n \ m dvd fact n" by (induct n) (auto simp: dvdI le_Suc_eq) @@ -112,7 +112,7 @@ lemma fact_altdef: "fact n = (\i=1..n. of_nat i)" by (induct n) (auto simp: atLeastAtMostSuc_conv) - + lemma fact_altdef': "fact n = of_nat (\{1..n})" by (subst fact_altdef_nat [symmetric]) simp @@ -145,7 +145,7 @@ from this \m = n + d\ show ?thesis by simp qed -lemma fact_num_eq_if: +lemma fact_num_eq_if: "fact m = (if m=0 then 1 else of_nat m * fact (m - 1))" by (cases m) auto @@ -402,20 +402,20 @@ lemma sum_choose_upper: "(\k=0..n. k choose m) = Suc n choose Suc m" by (induct n) auto -lemma choose_alternating_sum: +lemma choose_alternating_sum: "n > 0 \ (\i\n. (-1)^i * of_nat (n choose i)) = (0 :: 'a :: comm_ring_1)" using binomial_ring[of "-1 :: 'a" 1 n] by (simp add: atLeast0AtMost mult_of_nat_commute zero_power) lemma choose_even_sum: assumes "n > 0" shows "2 * (\i\n. if even i then of_nat (n choose i) else 0) = (2 ^ n :: 'a :: comm_ring_1)" -proof - +proof - have "2 ^ n = (\i\n. of_nat (n choose i)) + (\i\n. (-1) ^ i * of_nat (n choose i) :: 'a)" using choose_row_sum[of n] by (simp add: choose_alternating_sum assms atLeast0AtMost of_nat_setsum[symmetric] of_nat_power) also have "\ = (\i\n. of_nat (n choose i) + (-1) ^ i * of_nat (n choose i))" by (simp add: setsum.distrib) - also have "\ = 2 * (\i\n. if even i then of_nat (n choose i) else 0)" + also have "\ = 2 * (\i\n. if even i then of_nat (n choose i) else 0)" by (subst setsum_right_distrib, intro setsum.cong) simp_all finally show ?thesis .. qed @@ -423,13 +423,13 @@ lemma choose_odd_sum: assumes "n > 0" shows "2 * (\i\n. if odd i then of_nat (n choose i) else 0) = (2 ^ n :: 'a :: comm_ring_1)" -proof - +proof - have "2 ^ n = (\i\n. of_nat (n choose i)) - (\i\n. (-1) ^ i * of_nat (n choose i) :: 'a)" using choose_row_sum[of n] by (simp add: choose_alternating_sum assms atLeast0AtMost of_nat_setsum[symmetric] of_nat_power) also have "\ = (\i\n. of_nat (n choose i) - (-1) ^ i * of_nat (n choose i))" by (simp add: setsum_subtractf) - also have "\ = 2 * (\i\n. if odd i then of_nat (n choose i) else 0)" + also have "\ = 2 * (\i\n. if odd i then of_nat (n choose i) else 0)" by (subst setsum_right_distrib, intro setsum.cong) simp_all finally show ?thesis .. qed @@ -473,7 +473,7 @@ lemma pochhammer_Suc_setprod: "pochhammer a (Suc n) = setprod (\n. a + of_nat n) {0 .. n}" by (simp add: pochhammer_def) - + lemma pochhammer_of_nat: "pochhammer (of_nat x) n = of_nat (pochhammer x n)" by (simp add: pochhammer_def of_nat_setprod) @@ -525,10 +525,10 @@ lemma pochhammer_rec': "pochhammer z (Suc n) = (z + of_nat n) * pochhammer z n" proof (induction n arbitrary: z) case (Suc n z) - have "pochhammer z (Suc (Suc n)) = z * pochhammer (z + 1) (Suc n)" + have "pochhammer z (Suc (Suc n)) = z * pochhammer (z + 1) (Suc n)" by (simp add: pochhammer_rec) also note Suc - also have "z * ((z + 1 + of_nat n) * pochhammer (z + 1) n) = + also have "z * ((z + 1 + of_nat n) * pochhammer (z + 1) n) = (z + of_nat (Suc n)) * pochhammer z (Suc n)" by (simp_all add: pochhammer_rec algebra_simps) finally show ?case . @@ -621,11 +621,11 @@ unfolding pochhammer_minus by (simp add: of_nat_diff pochhammer_fact) -lemma pochhammer_product': +lemma pochhammer_product': "pochhammer z (n + m) = pochhammer z n * pochhammer (z + of_nat n) m" proof (induction n arbitrary: z) case (Suc n z) - have "pochhammer z (Suc n) * pochhammer (z + of_nat (Suc n)) m = + have "pochhammer z (Suc n) * pochhammer (z + of_nat (Suc n)) m = z * (pochhammer (z + 1) n * pochhammer (z + 1 + of_nat n) m)" by (simp add: pochhammer_rec ac_simps) also note Suc[symmetric] @@ -634,7 +634,7 @@ finally show ?case by simp qed simp -lemma pochhammer_product: +lemma pochhammer_product: "m \ n \ pochhammer z n = pochhammer z m * pochhammer (z + of_nat m) (n - m)" using pochhammer_product'[of z m "n - m"] by simp @@ -645,7 +645,7 @@ case (Suc n) def n' \ "Suc n" have "pochhammer z (Suc n') * pochhammer (z + 1 / 2) (Suc n') = - (pochhammer z n' * pochhammer (z + 1 / 2) n') * + (pochhammer z n' * pochhammer (z + 1 / 2) n') * ((z + of_nat n') * (z + 1/2 + of_nat n'))" (is "_ = _ * ?A") by (simp_all add: pochhammer_rec' mult_ac) also have "?A = (z + of_nat (Suc (2 * n + 1)) / 2) * (z + of_nat (Suc (Suc (2 * n + 1))) / 2)" @@ -661,7 +661,7 @@ shows "pochhammer (2 * z) (2 * n) = of_nat (2^(2*n)) * pochhammer z n * pochhammer (z+1/2) n" proof (induction n) case (Suc n) - have "pochhammer (2 * z) (2 * (Suc n)) = pochhammer (2 * z) (2 * n) * + have "pochhammer (2 * z) (2 * (Suc n)) = pochhammer (2 * z) (2 * n) * (2 * (z + of_nat n)) * (2 * (z + of_nat n) + 1)" by (simp add: pochhammer_rec' ac_simps of_nat_mult) also note Suc @@ -673,7 +673,7 @@ qed simp lemma pochhammer_absorb_comp: - "((r :: 'a :: comm_ring_1) - of_nat k) * pochhammer (- r) k = r * pochhammer (-r + 1) k" + "((r :: 'a :: comm_ring_1) - of_nat k) * pochhammer (- r) k = r * pochhammer (-r + 1) k" (is "?lhs = ?rhs") proof - have "?lhs = -pochhammer (-r) (Suc k)" by (subst pochhammer_rec') (simp add: algebra_simps) @@ -714,7 +714,7 @@ finally show ?thesis by simp qed -lemma binomial_gbinomial: +lemma binomial_gbinomial: "of_nat (n choose k) = (of_nat n gchoose k :: 'a::field_char_0)" proof - { assume kn: "k > n" @@ -741,7 +741,7 @@ have ?thesis using kn apply (simp add: binomial_fact[OF kn, where ?'a = 'a] gbinomial_pochhammer field_simps pochhammer_Suc_setprod) - apply (simp add: pochhammer_Suc_setprod fact_altdef h + apply (simp add: pochhammer_Suc_setprod fact_altdef h of_nat_setprod setprod.distrib[symmetric] eq' del: One_nat_def power_Suc) unfolding setprod.union_disjoint[OF th0, unfolded eq3, of "of_nat:: nat \ 'a"] eq[unfolded h] unfolding mult.assoc @@ -817,19 +817,19 @@ (a gchoose Suc h) * (fact (Suc (Suc h))) + (a gchoose Suc (Suc h)) * (fact (Suc (Suc h)))" by (simp add: Suc field_simps del: fact.simps) - also have "... = (a gchoose Suc h) * of_nat (Suc (Suc h) * fact (Suc h)) + + also have "... = (a gchoose Suc h) * of_nat (Suc (Suc h) * fact (Suc h)) + (\i = 0..Suc h. a - of_nat i)" by (metis fact.simps(2) gbinomial_mult_fact' of_nat_fact of_nat_id) - also have "... = (fact (Suc h) * (a gchoose Suc h)) * of_nat (Suc (Suc h)) + + also have "... = (fact (Suc h) * (a gchoose Suc h)) * of_nat (Suc (Suc h)) + (\i = 0..Suc h. a - of_nat i)" by (simp only: fact.simps(2) mult.commute mult.left_commute of_nat_fact of_nat_id of_nat_mult) - also have "... = of_nat (Suc (Suc h)) * (\i = 0..h. a - of_nat i) + + also have "... = of_nat (Suc (Suc h)) * (\i = 0..h. a - of_nat i) + (\i = 0..Suc h. a - of_nat i)" by (metis gbinomial_mult_fact mult.commute) also have "... = (\i = 0..Suc h. a - of_nat i) + (of_nat h * (\i = 0..h. a - of_nat i) + 2 * (\i = 0..h. a - of_nat i))" by (simp add: field_simps) - also have "... = + also have "... = ((a gchoose Suc h) * (fact (Suc h)) * of_nat (Suc k)) + (\i\{0::nat..Suc h}. a - of_nat i)" unfolding gbinomial_mult_fact' by (simp add: comm_semiring_class.distrib field_simps Suc) @@ -842,7 +842,7 @@ also have "\ = (fact (Suc k)) * ((a + 1) gchoose (Suc k))" unfolding gbinomial_mult_fact .. finally show ?thesis - by (metis fact_nonzero mult_cancel_left) + by (metis fact_nonzero mult_cancel_left) qed lemma gbinomial_reduce_nat: @@ -887,7 +887,7 @@ case (Suc m) have "(\i\n. i * (n choose i)) = (\i\Suc m. i * (Suc m choose i))" by (simp add: Suc) also have "... = Suc m * 2 ^ m" - by (simp only: setsum_atMost_Suc_shift Suc_times_binomial setsum_right_distrib[symmetric]) + by (simp only: setsum_atMost_Suc_shift Suc_times_binomial setsum_right_distrib[symmetric]) (simp add: choose_row_sum') finally show ?thesis using Suc by simp qed simp_all @@ -898,7 +898,7 @@ proof (cases n) case (Suc m) with assms have "m > 0" by simp - have "(\i\n. (-1) ^ i * of_nat i * of_nat (n choose i) :: 'a) = + have "(\i\n. (-1) ^ i * of_nat i * of_nat (n choose i) :: 'a) = (\i\Suc m. (-1) ^ i * of_nat i * of_nat (Suc m choose i))" by (simp add: Suc) also have "... = (\i\m. (-1) ^ (Suc i) * of_nat (Suc i * (Suc m choose Suc i)))" by (simp only: setsum_atMost_Suc_shift setsum_right_distrib[symmetric] of_nat_mult mult_ac) simp @@ -940,7 +940,7 @@ also have "(\i\n. of_nat (n choose i) * pochhammer a (Suc i) * pochhammer b (n - i)) = a * pochhammer ((a + 1) + b) n" by (subst Suc) (simp add: setsum_right_distrib pochhammer_rec mult_ac) - also have "(\i\n. of_nat (n choose Suc i) * pochhammer a (Suc i) * pochhammer b (n - i)) + pochhammer b (Suc n) = + also have "(\i\n. of_nat (n choose Suc i) * pochhammer a (Suc i) * pochhammer b (n - i)) + pochhammer b (Suc n) = (\i=0..Suc n. of_nat (n choose i) * pochhammer a i * pochhammer b (Suc n - i))" by (subst setsum_head_Suc, simp, subst setsum_shift_bounds_cl_Suc_ivl) (simp add: atLeast0AtMost) also have "... = (\i\n. of_nat (n choose i) * pochhammer a i * pochhammer b (Suc n - i))" @@ -1010,7 +1010,7 @@ "of_nat (Suc b) * ((a + 1) gchoose (Suc b)) = (a + 1) * (a gchoose b)" proof (cases b) case (Suc b) - hence "((a + 1) gchoose (Suc (Suc b))) = + hence "((a + 1) gchoose (Suc (Suc b))) = (\i = 0..Suc b. a + (1 - of_nat i)) / fact (b + 2)" by (simp add: field_simps gbinomial_def) also have "(\i = 0..Suc b. a + (1 - of_nat i)) = (a + 1) * (\i = 0..b. a - of_nat i)" @@ -1024,7 +1024,7 @@ "((a + 1) gchoose (Suc b)) = (a + 1) / of_nat (Suc b) * (a gchoose b)" proof (cases b) case (Suc b) - hence "((a + 1) gchoose (Suc (Suc b))) = + hence "((a + 1) gchoose (Suc (Suc b))) = (\i = 0..Suc b. a + (1 - of_nat i)) / fact (b + 2)" by (simp add: field_simps gbinomial_def) also have "(\i = 0..Suc b. a + (1 - of_nat i)) = (a + 1) * (\i = 0..b. a - of_nat i)" @@ -1045,9 +1045,9 @@ text \The absorption identity (equation 5.5 \cite[p.~157]{GKP}):\[ {r \choose k} = \frac{r}{k}{r - 1 \choose k - 1},\quad \textnormal{integer } k \neq 0. \]\ -lemma gbinomial_absorption': +lemma gbinomial_absorption': "k > 0 \ (r gchoose k) = (r / of_nat(k)) * (r - 1 gchoose (k - 1))" - using gbinomial_rec[of "r - 1" "k - 1"] + using gbinomial_rec[of "r - 1" "k - 1"] by (simp_all add: gbinomial_rec field_simps del: of_nat_Suc) text \The absorption identity is written in the following form to avoid @@ -1096,7 +1096,7 @@ summation formula, operating on both indices:\[ \sum\limits_{k \leq n}{r + k \choose k} = {r + n + 1 \choose n}, \quad \textnormal{integer } n. - \] + \] \ lemma gbinomial_parallel_sum: "(\k\n. (r + of_nat k) gchoose k) = (r + of_nat n + 1) gchoose n" @@ -1108,7 +1108,7 @@ subsection \Summation on the upper index\ text \ Another summation formula is equation 5.10 of the reference material \cite[p.~160]{GKP}, - aptly named \emph{summation on the upper index}:\[\sum_{0 \leq k \leq n} {k \choose m} = + aptly named \emph{summation on the upper index}:\[\sum_{0 \leq k \leq n} {k \choose m} = {n + 1 \choose m + 1}, \quad \textnormal{integers } m, n \geq 0.\] \ lemma gbinomial_sum_up_index: @@ -1121,7 +1121,7 @@ thus ?case using gbinomial_Suc_Suc[of "of_nat (Suc n) :: 'a" m] by (simp add: add_ac) qed -lemma gbinomial_index_swap: +lemma gbinomial_index_swap: "((-1) ^ m) * ((- (of_nat n) - 1) gchoose m) = ((-1) ^ n) * ((- (of_nat m) - 1) gchoose n)" (is "?lhs = ?rhs") proof - @@ -1132,7 +1132,7 @@ finally show ?thesis . qed -lemma gbinomial_sum_lower_neg: +lemma gbinomial_sum_lower_neg: "(\k\m. (r gchoose k) * (- 1) ^ k) = (- 1) ^ m * (r - 1 gchoose m)" (is "?lhs = ?rhs") proof - have "?lhs = (\k\m. -(r + 1) + of_nat k gchoose k)" @@ -1146,7 +1146,7 @@ "(\k\m. (r gchoose k) * ((r / 2) - of_nat k)) = ((of_nat m + 1)/2) * (r gchoose (m + 1))" proof (induction m) case (Suc mm) - hence "(\k\Suc mm. (r gchoose k) * (r / 2 - of_nat k)) = + hence "(\k\Suc mm. (r gchoose k) * (r / 2 - of_nat k)) = (r - of_nat (Suc mm)) * (r gchoose Suc mm) / 2" by (simp add: field_simps) also have "\ = r * (r - 1 gchoose Suc mm) / 2" by (subst gbinomial_absorb_comp) (rule refl) also have "\ = (of_nat (Suc mm) + 1) / 2 * (r gchoose (Suc mm + 1))" @@ -1175,10 +1175,10 @@ also have "\ = (\k=0..mm. (of_nat mm + r gchoose (Suc k)) * x^(Suc k) * y^(mm - k)) + (\k=0..mm. (of_nat mm + r gchoose k) * x^(Suc k) * y^(mm - k))" by (subst setsum.distrib [symmetric]) (simp add: algebra_simps) - also have "(\k=0..mm. (of_nat mm + r gchoose (Suc k)) * x^(Suc k) * y^(mm - k)) = + also have "(\k=0..mm. (of_nat mm + r gchoose (Suc k)) * x^(Suc k) * y^(mm - k)) = (\k = (\k = (\kk=1..mm. (of_nat mm + r gchoose k) * x^k * y^(mm - k + 1))" @@ -1188,17 +1188,17 @@ thus "(of_nat mm + r gchoose Suc k) * x ^ Suc k * y ^ (mm - k) = (of_nat mm + r gchoose Suc k) * x ^ Suc k * y ^ (mm - Suc k + 1)" by (simp only:) qed - also have "\ + ?B = y * (\k=1..mm. (G mm k)) + (of_nat mm + r gchoose (Suc mm)) * x^(Suc mm)" + also have "\ + ?B = y * (\k=1..mm. (G mm k)) + (of_nat mm + r gchoose (Suc mm)) * x^(Suc mm)" unfolding G_def by (subst setsum_right_distrib) (simp add: algebra_simps) also have "(\k=0..mm. (of_nat mm + r gchoose k) * x^(Suc k) * y^(mm - k)) = x * (S mm)" unfolding S_def by (subst setsum_right_distrib) (simp add: atLeast0AtMost algebra_simps) also have "(G (Suc mm) 0) = y * (G mm 0)" by (simp add: G_def) - finally have "S (Suc mm) = y * ((G mm 0) + (\k=1..mm. (G mm k))) + finally have "S (Suc mm) = y * ((G mm 0) + (\k=1..mm. (G mm k))) + (of_nat mm + r gchoose (Suc mm)) * x^(Suc mm) + x * (S mm)" by (simp add: ring_distribs) - also have "(G mm 0) + (\k=1..mm. (G mm k)) = S mm" + also have "(G mm 0) + (\k=1..mm. (G mm k)) = S mm" by (simp add: setsum_head_Suc[symmetric] SG_def atLeast0AtMost) - finally have "S (Suc mm) = (x + y) * (S mm) + (of_nat mm + r gchoose (Suc mm)) * x^(Suc mm)" + finally have "S (Suc mm) = (x + y) * (S mm) + (of_nat mm + r gchoose (Suc mm)) * x^(Suc mm)" by (simp add: algebra_simps) also have "(of_nat mm + r gchoose (Suc mm)) = (-1) ^ (Suc mm) * (-r gchoose (Suc mm))" by (subst gbinomial_negated_upper) simp @@ -1208,13 +1208,13 @@ unfolding S_def by (subst Suc.IH) simp also have "(x + y) * ?rhs mm = (\n\mm. ((- r gchoose n) * (- x) ^ n * (x + y) ^ (Suc mm - n)))" by (subst setsum_right_distrib, rule setsum.cong) (simp_all add: Suc_diff_le) - also have "\ + (-r gchoose (Suc mm)) * (-x)^Suc mm = + also have "\ + (-r gchoose (Suc mm)) * (-x)^Suc mm = (\n\Suc mm. (- r gchoose n) * (- x) ^ n * (x + y) ^ (Suc mm - n))" by simp finally show ?case unfolding S_def . qed simp_all lemma gbinomial_partial_sum_poly_xpos: - "(\k\m. (of_nat m + r gchoose k) * x^k * y^(m-k)) = + "(\k\m. (of_nat m + r gchoose k) * x^k * y^(m-k)) = (\k\m. (of_nat k + r - 1 gchoose k) * x^k * (x + y)^(m-k))" apply (subst gbinomial_partial_sum_poly) apply (subst gbinomial_negated_upper) @@ -1222,7 +1222,7 @@ apply (simp add: power_mult_distrib [symmetric]) done -lemma setsum_nat_symmetry: +lemma setsum_nat_symmetry: "(\k = 0..(m::nat). f k) = (\k = 0..m. f (m - k))" by (rule setsum.reindex_bij_witness[where i="\i. m - i" and j="\i. m - i"]) auto @@ -1247,7 +1247,7 @@ lemma gbinomial_r_part_sum: "(\k\m. (2 * (of_nat m) + 1 gchoose k)) = 2 ^ (2 * m)" (is "?lhs = ?rhs") proof - - have "?lhs = of_nat (\k\m. (2 * m + 1) choose k)" + have "?lhs = of_nat (\k\m. (2 * m + 1) choose k)" by (simp add: binomial_gbinomial of_nat_mult add_ac of_nat_setsum) also have "\ = of_nat (2 ^ (2 * m))" by (subst binomial_r_part_sum) (rule refl) finally show ?thesis by (simp add: of_nat_power) @@ -1270,7 +1270,7 @@ assumes "k \ m" shows "(r gchoose m) * (of_nat m gchoose k) = (r gchoose k) * (r - of_nat k gchoose (m - k))" proof - - have "(r gchoose m) * (of_nat m gchoose k) = + have "(r gchoose m) * (of_nat m gchoose k) = (r gchoose m) * fact m / (fact k * fact (m - k))" using assms by (simp add: binomial_gbinomial [symmetric] binomial_fact) also have "\ = (r gchoose k) * (r - of_nat k gchoose (m - k))" using assms @@ -1315,7 +1315,7 @@ apply (auto simp: of_nat_mult) done -lemma fact_fact_dvd_fact: +lemma fact_fact_dvd_fact: "fact k * fact n dvd (fact (k+n) :: 'a :: {semiring_div,linordered_semidom})" by (metis add.commute add_diff_cancel_left' choose_dvd le_add2) @@ -1568,12 +1568,12 @@ qed lemma pochhammer_code [code]: - "pochhammer a n = (if n = 0 then 1 else + "pochhammer a n = (if n = 0 then 1 else fold_atLeastAtMost_nat (\n acc. (a + of_nat n) * acc) 0 (n - 1) 1)" by (simp add: setprod_atLeastAtMost_code pochhammer_def) lemma gbinomial_code [code]: - "a gchoose n = (if n = 0 then 1 else + "a gchoose n = (if n = 0 then 1 else fold_atLeastAtMost_nat (\n acc. (a - of_nat n) * acc) 0 (n - 1) 1 / fact n)" by (simp add: setprod_atLeastAtMost_code gbinomial_def) @@ -1593,7 +1593,7 @@ by (simp add: setprod.union_disjoint fact_altdef_nat) } thus ?thesis by (auto simp: binomial_altdef_nat mult_ac setprod_atLeastAtMost_code) -qed +qed *) end diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Decision_Procs/Polynomial_List.thy --- a/src/HOL/Decision_Procs/Polynomial_List.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Decision_Procs/Polynomial_List.thy Fri Feb 19 13:40:50 2016 +0100 @@ -572,13 +572,7 @@ done lemma (in comm_semiring_1) poly_divides_exp: "m \ n \ (p %^ m) divides (p %^ n)" - apply (auto simp add: le_iff_add) - apply (induct_tac k) - apply (rule_tac [2] poly_divides_trans) - apply (auto simp add: divides_def) - apply (rule_tac x = p in exI) - apply (auto simp add: poly_mult fun_eq_iff ac_simps) - done + by (auto simp: le_iff_add divides_def poly_exp_add fun_eq_iff) lemma (in comm_semiring_1) poly_exp_divides: "(p %^ n) divides q \ m \ n \ (p %^ m) divides q" by (blast intro: poly_divides_exp poly_divides_trans) diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Filter.thy --- a/src/HOL/Filter.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Filter.thy Fri Feb 19 13:40:50 2016 +0100 @@ -490,7 +490,7 @@ shows "\\<^sub>F x in \i\I. F' i. T P x" proof - from * obtain X where "finite X" "X \ I" "\\<^sub>F x in \i\X. F i. P x" - unfolding eventually_INF[of _ I] by auto + unfolding eventually_INF[of _ _ I] by auto moreover then have "eventually (T P) (INFIMUM X F')" apply (induction X arbitrary: P) apply (auto simp: eventually_inf T2) diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Groups.thy --- a/src/HOL/Groups.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Groups.thy Fri Feb 19 13:40:50 2016 +0100 @@ -753,6 +753,13 @@ end class strict_ordered_comm_monoid_add = comm_monoid_add + strict_ordered_ab_semigroup_add +begin + +lemma pos_add_strict: + shows "0 < a \ b < c \ b < a + c" + using add_strict_mono [of 0 a b c] by simp + +end class ordered_cancel_comm_monoid_add = ordered_comm_monoid_add + cancel_ab_semigroup_add begin @@ -1311,15 +1318,37 @@ assumes le_iff_add: "a \ b \ (\c. b = a + c)" begin -lemma zero_le: "0 \ x" +lemma zero_le[simp]: "0 \ x" by (auto simp: le_iff_add) +lemma le_zero_eq[simp]: "n \ 0 \ n = 0" + by (auto intro: antisym) + +lemma not_less_zero[simp]: "\ n < 0" + by (auto simp: less_le) + +lemma zero_less_iff_neq_zero: "(0 < n) \ (n \ 0)" + by (auto simp: less_le) + +text \This theorem is useful with \blast\\ +lemma gr_zeroI: "(n = 0 \ False) \ 0 < n" + by (rule zero_less_iff_neq_zero[THEN iffD2]) iprover + +lemma not_gr_zero[simp]: "(\ (0 < n)) \ (n = 0)" + by (simp add: zero_less_iff_neq_zero) + subclass ordered_comm_monoid_add proof qed (auto simp: le_iff_add add_ac) lemma add_eq_0_iff_both_eq_0: "x + y = 0 \ x = 0 \ y = 0" by (intro add_nonneg_eq_0_iff zero_le) +lemma gr_implies_not_zero: "m < n \ n \ 0" + using add_eq_0_iff_both_eq_0[of m] by (auto simp: le_iff_add less_le) + +lemmas zero_order = zero_le le_zero_eq not_less_zero zero_less_iff_neq_zero not_gr_zero + -- \This should be attributed with \[iff]\, but then \blast\ fails in \Set\.\ + end class ordered_cancel_comm_monoid_diff = diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Groups_Big.thy Fri Feb 19 13:40:50 2016 +0100 @@ -1195,6 +1195,6 @@ lemma setprod_pos_nat_iff [simp]: "finite A \ setprod f A > 0 \ (\a\A. f a > (0::nat))" - using setprod_zero_iff by (simp del:neq0_conv add:neq0_conv [symmetric]) + using setprod_zero_iff by (simp del: neq0_conv add: zero_less_iff_neq_zero) end diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/IMP/Abs_Int_ITP/Abs_Int1_ITP.thy --- a/src/HOL/IMP/Abs_Int_ITP/Abs_Int1_ITP.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/IMP/Abs_Int_ITP/Abs_Int1_ITP.thy Fri Feb 19 13:40:50 2016 +0100 @@ -172,26 +172,6 @@ text{* ACC for abstract states, via measure functions. *} -(*FIXME mv*) -lemma setsum_strict_mono1: -fixes f :: "'a \ 'b::{comm_monoid_add, ordered_cancel_ab_semigroup_add}" -assumes "finite A" and "ALL x:A. f x \ g x" and "EX a:A. f a < g a" -shows "setsum f A < setsum g A" -proof- - from assms(3) obtain a where a: "a:A" "f a < g a" by blast - have "setsum f A = setsum f ((A-{a}) \ {a})" - by(simp add:insert_absorb[OF `a:A`]) - also have "\ = setsum f (A-{a}) + setsum f {a}" - using `finite A` by(subst setsum.union_disjoint) auto - also have "setsum f (A-{a}) \ setsum g (A-{a})" - by(rule setsum_mono)(simp add: assms(2)) - also have "setsum f {a} < setsum g {a}" using a by simp - also have "setsum g (A - {a}) + setsum g {a} = setsum g((A-{a}) \ {a})" - using `finite A` by(subst setsum.union_disjoint[symmetric]) auto - also have "\ = setsum g A" by(simp add:insert_absorb[OF `a:A`]) - finally show ?thesis by (metis add_right_mono add_strict_left_mono) -qed - lemma measure_st: assumes "(strict{(x,y::'a::SL_top). x \ y})^-1 <= measure m" and "\x y::'a::SL_top. x \ y \ y \ x \ m x = m y" shows "(strict{(S,S'::'a::SL_top st). S \ S'})^-1 \ @@ -223,7 +203,7 @@ by (fastforce simp: le_st_def lookup_def) have "(\y\?Y'\?X. m(?g y)+1) < (\y\?Y'\?X. m(?f y)+1)" using `u:?X` `u:?Y'` `m(?g u) < m(?f u)` - by(fastforce intro!: setsum_strict_mono1[OF _ 1]) + by(fastforce intro!: setsum_strict_mono_ex1[OF _ 1]) also have "\ \ (\y\?X'. m(?f y)+1)" by(simp add: setsum_mono3[OF _ `?Y'\?X <= ?X'`]) finally show ?thesis . diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/IMP/Abs_Int_ITP/Abs_Int3_ITP.thy --- a/src/HOL/IMP/Abs_Int_ITP/Abs_Int3_ITP.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/IMP/Abs_Int_ITP/Abs_Int3_ITP.thy Fri Feb 19 13:40:50 2016 +0100 @@ -340,7 +340,7 @@ proof cases assume "x : ?Y" have "?L < (\x\?X\?Y. m_ivl(?f x))" - proof(rule setsum_strict_mono1, simp) + proof(rule setsum_strict_mono_ex1, simp) show "\x\?X\?Y. m_ivl(?f x \ ?g x) \ m_ivl (?f x)" by (metis m_ivl_anti_mono widen1) next @@ -395,7 +395,7 @@ by(auto simp: le_st_def narrow_st_def lookup_def intro: n_ivl_narrow split: if_splits) have "(\x\X. n_ivl(lookup (S1 \ S2) x)) < (\x\X. n_ivl(lookup S1 x))" - apply(rule setsum_strict_mono1[OF `finite X`]) using 1 2 by blast+ + apply(rule setsum_strict_mono_ex1[OF `finite X`]) using 1 2 by blast+ thus ?thesis by(simp add: n_st_def) qed @@ -501,7 +501,7 @@ apply(subgoal_tac "length(annos c') = length(annos c)") prefer 2 apply (simp add: size_annos_same2) apply (auto) -apply(rule setsum_strict_mono1) +apply(rule setsum_strict_mono_ex1) apply simp apply (clarsimp) apply(erule m_o_anti_mono) @@ -522,7 +522,7 @@ apply(subgoal_tac "length(annos c') = length(annos c)") prefer 2 apply (simp add: size_annos_same2) apply (auto) -apply(rule setsum_strict_mono1) +apply(rule setsum_strict_mono_ex1) apply simp apply (clarsimp) apply(rule n_o_mono) diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Library/Extended_Nat.thy --- a/src/HOL/Library/Extended_Nat.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Library/Extended_Nat.thy Fri Feb 19 13:40:50 2016 +0100 @@ -12,6 +12,18 @@ class infinity = fixes infinity :: "'a" ("\") +context + fixes f :: "nat \ 'a::{canonically_ordered_monoid_add, linorder_topology, complete_linorder}" +begin + +lemma sums_SUP[simp, intro]: "f sums (SUP n. \iiType definition\ text \ @@ -71,7 +83,7 @@ subsection \Constructors and numbers\ -instantiation enat :: "{zero, one}" +instantiation enat :: zero_neq_one begin definition @@ -80,7 +92,8 @@ definition "1 = enat 1" -instance .. +instance + proof qed (simp add: zero_enat_def one_enat_def) end @@ -108,7 +121,7 @@ lemma i0_ne_infinity [simp]: "0 \ (\::enat)" by (simp add: zero_enat_def) -lemma zero_one_enat_neq [simp]: +lemma zero_one_enat_neq: "\ 0 = (1::enat)" "\ 1 = (0::enat)" unfolding zero_enat_def one_enat_def by simp_all @@ -183,12 +196,9 @@ lemma iadd_Suc_right: "m + eSuc n = eSuc (m + n)" by (simp only: add.commute[of m] iadd_Suc) -lemma iadd_is_0: "(m + n = (0::enat)) = (m = 0 \ n = 0)" - by (cases m, cases n, simp_all add: zero_enat_def) - subsection \Multiplication\ -instantiation enat :: comm_semiring_1 +instantiation enat :: "{comm_semiring_1, semiring_no_zero_divisors}" begin definition times_enat_def [nitpick_simp]: @@ -209,13 +219,13 @@ show "(a * b) * c = a * (b * c)" unfolding times_enat_def zero_enat_def by (simp split: enat.split) - show "a * b = b * a" + show comm: "a * b = b * a" unfolding times_enat_def zero_enat_def by (simp split: enat.split) show "1 * a = a" unfolding times_enat_def zero_enat_def one_enat_def by (simp split: enat.split) - show "(a + b) * c = a * c + b * c" + show distr: "(a + b) * c = a * c + b * c" unfolding times_enat_def zero_enat_def by (simp split: enat.split add: distrib_right) show "0 * a = 0" @@ -224,9 +234,10 @@ show "a * 0 = 0" unfolding times_enat_def zero_enat_def by (simp split: enat.split) - show "(0::enat) \ 1" - unfolding zero_enat_def one_enat_def - by simp + show "a * (b + c) = a * b + a * c" + by (cases a b c rule: enat3_cases) (auto simp: times_enat_def zero_enat_def distrib_left) + show "a \ 0 \ b \ 0 \ a * b \ 0" + by (cases a b rule: enat2_cases) (auto simp: times_enat_def zero_enat_def) qed end @@ -249,13 +260,9 @@ then show "inj (\n. of_nat n :: enat)" by (simp add: of_nat_eq_enat) qed -lemma imult_is_0 [simp]: "((m::enat) * n = 0) = (m = 0 \ n = 0)" - by (auto simp add: times_enat_def zero_enat_def split: enat.split) - lemma imult_is_infinity: "((a::enat) * b = \) = (a = \ \ b \ 0 \ b = \ \ a \ 0)" by (auto simp add: times_enat_def zero_enat_def split: enat.split) - subsection \Numerals\ lemma numeral_eq_enat: @@ -368,13 +375,15 @@ by (cases a b rule: enat2_cases) (auto simp: le_iff_add enat_ex_split) qed -instance enat :: "ordered_comm_semiring" +instance enat :: "{linordered_nonzero_semiring, strict_ordered_comm_monoid_add}" proof fix a b c :: enat - assume "a \ b" and "0 \ c" thus "c * a \ c * b" + show "a \ b \ 0 \ c \c * a \ c * b" unfolding times_enat_def less_eq_enat_def zero_enat_def by (simp split: enat.splits) -qed + show "a < b \ c < d \ a + c < b + d" for a b c d :: enat + by (cases a b c d rule: enat2_cases[case_product enat2_cases]) auto +qed (simp add: zero_enat_def one_enat_def) (* BH: These equations are already proven generally for any type in class linordered_semidom. However, enat is not in that class because @@ -386,24 +395,12 @@ "(numeral m :: enat) < numeral n \ (numeral m :: nat) < numeral n" by (simp_all add: numeral_eq_enat) -lemma i0_lb [simp]: "(0::enat) \ n" - by (simp add: zero_enat_def less_eq_enat_def split: enat.splits) - -lemma ile0_eq [simp]: "n \ (0::enat) \ n = 0" - by (simp add: zero_enat_def less_eq_enat_def split: enat.splits) - lemma infinity_ileE [elim!]: "\ \ enat m \ R" by (simp add: zero_enat_def less_eq_enat_def split: enat.splits) lemma infinity_ilessE [elim!]: "\ < enat m \ R" by simp -lemma not_iless0 [simp]: "\ n < (0::enat)" - by (simp add: zero_enat_def less_enat_def split: enat.splits) - -lemma i0_less [simp]: "(0::enat) < n \ n \ 0" - by (simp add: zero_enat_def less_enat_def split: enat.splits) - lemma eSuc_ile_mono [simp]: "eSuc n \ eSuc m \ n \ m" by (simp add: eSuc_def less_eq_enat_def split: enat.splits) @@ -438,12 +435,11 @@ by (simp add: zero_enat_def less_enat_def split: enat.splits) lemma enat_0_less_mult_iff: "(0 < (m::enat) * n) = (0 < m \ 0 < n)" - by (simp only: i0_less imult_is_0, simp) + by (simp only: zero_less_iff_neq_zero mult_eq_0_iff, simp) lemma mono_eSuc: "mono eSuc" by (simp add: mono_def) - lemma min_enat_simps [simp]: "min (enat m) (enat n) = enat (min m n)" "min q 0 = 0" @@ -470,10 +466,10 @@ "x + y \ enat n \ (\y' x'. x = enat x' \ y = enat y' \ x' + y' \ n)" by(cases x y rule: enat.exhaust[case_product enat.exhaust]) simp_all -lemma chain_incr: "\i. \j. Y i < Y j ==> \j. enat k < Y j" +lemma chain_incr: "\i. \j. Y i < Y j \ \j. enat k < Y j" apply (induct_tac k) apply (simp (no_asm) only: enat_0) - apply (fast intro: le_less_trans [OF i0_lb]) + apply (fast intro: le_less_trans [OF zero_le]) apply (erule exE) apply (drule spec) apply (erule exE) @@ -678,4 +674,22 @@ lemmas enat_defs = zero_enat_def one_enat_def eSuc_def plus_enat_def less_eq_enat_def less_enat_def +lemma iadd_is_0: "(m + n = (0::enat)) = (m = 0 \ n = 0)" + by (rule add_eq_0_iff_both_eq_0) + +lemma i0_lb : "(0::enat) \ n" + by (rule zero_le) + +lemma ile0_eq: "n \ (0::enat) \ n = 0" + by (rule le_zero_eq) + +lemma not_iless0: "\ n < (0::enat)" + by (rule not_less_zero) + +lemma i0_less[simp]: "(0::enat) < n \ n \ 0" + by (rule zero_less_iff_neq_zero) + +lemma imult_is_0: "((m::enat) * n = 0) = (m = 0 \ n = 0)" + by (rule mult_eq_0_iff) + end diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Library/Extended_Nonnegative_Real.thy --- a/src/HOL/Library/Extended_Nonnegative_Real.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Library/Extended_Nonnegative_Real.thy Fri Feb 19 13:40:50 2016 +0100 @@ -8,20 +8,117 @@ imports Extended_Real begin +context linordered_nonzero_semiring +begin + +lemma of_nat_nonneg [simp]: "0 \ of_nat n" + by (induct n) simp_all + +lemma of_nat_mono[simp]: "i \ j \ of_nat i \ of_nat j" + by (auto simp add: le_iff_add intro!: add_increasing2) + +end + +lemma of_nat_less[simp]: + "i < j \ of_nat i < (of_nat j::'a::{linordered_nonzero_semiring, semiring_char_0})" + by (auto simp: less_le) + +lemma of_nat_le_iff[simp]: + "of_nat i \ (of_nat j::'a::{linordered_nonzero_semiring, semiring_char_0}) \ i \ j" +proof (safe intro!: of_nat_mono) + assume "of_nat i \ (of_nat j::'a)" then show "i \ j" + proof (intro leI notI) + assume "j < i" from less_le_trans[OF of_nat_less[OF this] \of_nat i \ of_nat j\] show False + by blast + qed +qed + +lemma (in complete_lattice) SUP_sup_const1: + "I \ {} \ (SUP i:I. sup c (f i)) = sup c (SUP i:I. f i)" + using SUP_sup_distrib[of "\_. c" I f] by simp + +lemma (in complete_lattice) SUP_sup_const2: + "I \ {} \ (SUP i:I. sup (f i) c) = sup (SUP i:I. f i) c" + using SUP_sup_distrib[of f I "\_. c"] by simp + +lemma one_less_of_natD: + "(1::'a::linordered_semidom) < of_nat n \ 1 < n" + using zero_le_one[where 'a='a] + apply (cases n) + apply simp + subgoal for n' + apply (cases n') + apply simp + apply simp + done + done + +lemma setsum_le_suminf: + fixes f :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" + shows "summable f \ finite I \ \m\- I. 0 \ f m \ setsum f I \ suminf f" + by (rule sums_le[OF _ sums_If_finite_set summable_sums]) auto + typedef ennreal = "{x :: ereal. 0 \ x}" - morphisms enn2ereal e2ennreal + morphisms enn2ereal e2ennreal' by auto -setup_lifting type_definition_ennreal +definition "e2ennreal x = e2ennreal' (max 0 x)" +lemma type_definition_ennreal': "type_definition enn2ereal e2ennreal {x. 0 \ x}" + using type_definition_ennreal + by (auto simp: type_definition_def e2ennreal_def max_absorb2) -lift_definition ennreal :: "real \ ennreal" is "max 0 \ ereal" +setup_lifting type_definition_ennreal' + +lift_definition ennreal :: "real \ ennreal" is "sup 0 \ ereal" by simp declare [[coercion ennreal]] declare [[coercion e2ennreal]] -instantiation ennreal :: semiring_1_no_zero_divisors +instantiation ennreal :: complete_linorder +begin + +lift_definition top_ennreal :: ennreal is top by (rule top_greatest) +lift_definition bot_ennreal :: ennreal is 0 by (rule order_refl) +lift_definition sup_ennreal :: "ennreal \ ennreal \ ennreal" is sup by (rule le_supI1) +lift_definition inf_ennreal :: "ennreal \ ennreal \ ennreal" is inf by (rule le_infI) + +lift_definition Inf_ennreal :: "ennreal set \ ennreal" is "Inf" + by (rule Inf_greatest) + +lift_definition Sup_ennreal :: "ennreal set \ ennreal" is "sup 0 \ Sup" + by auto + +lift_definition less_eq_ennreal :: "ennreal \ ennreal \ bool" is "op \" . +lift_definition less_ennreal :: "ennreal \ ennreal \ bool" is "op <" . + +instance + by standard + (transfer ; auto simp: Inf_lower Inf_greatest Sup_upper Sup_least le_max_iff_disj max.absorb1)+ + +end + +lemma ennreal_cases: + fixes x :: ennreal + obtains (real) r :: real where "0 \ r" "x = ennreal r" | (top) "x = top" + apply transfer + subgoal for x thesis + by (cases x) (auto simp: max.absorb2 top_ereal_def) + done + +instantiation ennreal :: infinity +begin + +definition infinity_ennreal :: ennreal +where + [simp]: "\ = (top::ennreal)" + +instance .. + +end + +instantiation ennreal :: "{semiring_1_no_zero_divisors, comm_semiring_1}" begin lift_definition one_ennreal :: ennreal is 1 by simp @@ -34,6 +131,16 @@ end +instantiation ennreal :: minus +begin + +lift_definition minus_ennreal :: "ennreal \ ennreal \ ennreal" is "\a b. max 0 (a - b)" + by simp + +instance .. + +end + instance ennreal :: numeral .. instantiation ennreal :: inverse @@ -49,32 +156,6 @@ end - -instantiation ennreal :: complete_linorder -begin - -lift_definition top_ennreal :: ennreal is top by simp -lift_definition bot_ennreal :: ennreal is 0 by simp -lift_definition sup_ennreal :: "ennreal \ ennreal \ ennreal" is sup by (simp add: max.coboundedI1) -lift_definition inf_ennreal :: "ennreal \ ennreal \ ennreal" is inf by (simp add: min.boundedI) - -lift_definition Inf_ennreal :: "ennreal set \ ennreal" is "Inf" - by (auto intro: Inf_greatest) - -lift_definition Sup_ennreal :: "ennreal set \ ennreal" is "sup 0 \ Sup" - by auto - -lift_definition less_eq_ennreal :: "ennreal \ ennreal \ bool" is "op \" . -lift_definition less_ennreal :: "ennreal \ ennreal \ bool" is "op <" . - -instance - by standard - (transfer ; auto simp: Inf_lower Inf_greatest Sup_upper Sup_least le_max_iff_disj max.absorb1)+ - -end - - - lemma ennreal_zero_less_one: "0 < (1::ennreal)" by transfer auto @@ -89,6 +170,96 @@ by standard (transfer ; auto intro: add_mono mult_mono mult_ac ereal_left_distrib ereal_mult_left_mono)+ +instance ennreal :: linordered_nonzero_semiring + proof qed (transfer; simp) + +declare [[coercion "of_nat :: nat \ ennreal"]] + +lemma e2ennreal_neg: "x \ 0 \ e2ennreal x = 0" + unfolding zero_ennreal_def e2ennreal_def by (simp add: max_absorb1) + +lemma e2ennreal_mono: "x \ y \ e2ennreal x \ e2ennreal y" + by (cases "0 \ x" "0 \ y" rule: bool.exhaust[case_product bool.exhaust]) + (auto simp: e2ennreal_neg less_eq_ennreal.abs_eq eq_onp_def) + +subsection \Cancellation simprocs\ + +lemma ennreal_add_left_cancel: "a + b = a + c \ a = (\::ennreal) \ b = c" + unfolding infinity_ennreal_def by transfer (simp add: top_ereal_def ereal_add_cancel_left) + +lemma ennreal_add_left_cancel_le: "a + b \ a + c \ a = (\::ennreal) \ b \ c" + unfolding infinity_ennreal_def by transfer (simp add: ereal_add_le_add_iff top_ereal_def disj_commute) + +lemma ereal_add_left_cancel_less: + fixes a b c :: ereal + shows "0 \ a \ 0 \ b \ a + b < a + c \ a \ \ \ b < c" + by (cases a b c rule: ereal3_cases) auto + +lemma ennreal_add_left_cancel_less: "a + b < a + c \ a \ (\::ennreal) \ b < c" + unfolding infinity_ennreal_def + by transfer (simp add: top_ereal_def ereal_add_left_cancel_less) + +ML \ +structure Cancel_Ennreal_Common = +struct + (* copied from src/HOL/Tools/nat_numeral_simprocs.ML *) + fun find_first_t _ _ [] = raise TERM("find_first_t", []) + | find_first_t past u (t::terms) = + if u aconv t then (rev past @ terms) + else find_first_t (t::past) u terms + + fun dest_summing (Const (@{const_name Groups.plus}, _) $ t $ u, ts) = + dest_summing (t, dest_summing (u, ts)) + | dest_summing (t, ts) = t :: ts + + val mk_sum = Arith_Data.long_mk_sum + fun dest_sum t = dest_summing (t, []) + val find_first = find_first_t [] + val trans_tac = Numeral_Simprocs.trans_tac + val norm_ss = + simpset_of (put_simpset HOL_basic_ss @{context} + addsimps @{thms ac_simps add_0_left add_0_right}) + fun norm_tac ctxt = ALLGOALS (simp_tac (put_simpset norm_ss ctxt)) + fun simplify_meta_eq ctxt cancel_th th = + Arith_Data.simplify_meta_eq [] ctxt + ([th, cancel_th] MRS trans) + fun mk_eq (a, b) = HOLogic.mk_Trueprop (HOLogic.mk_eq (a, b)) +end + +structure Eq_Ennreal_Cancel = ExtractCommonTermFun +(open Cancel_Ennreal_Common + val mk_bal = HOLogic.mk_eq + val dest_bal = HOLogic.dest_bin @{const_name HOL.eq} @{typ ennreal} + fun simp_conv _ _ = SOME @{thm ennreal_add_left_cancel} +) + +structure Le_Ennreal_Cancel = ExtractCommonTermFun +(open Cancel_Ennreal_Common + val mk_bal = HOLogic.mk_binrel @{const_name Orderings.less_eq} + val dest_bal = HOLogic.dest_bin @{const_name Orderings.less_eq} @{typ ennreal} + fun simp_conv _ _ = SOME @{thm ennreal_add_left_cancel_le} +) + +structure Less_Ennreal_Cancel = ExtractCommonTermFun +(open Cancel_Ennreal_Common + val mk_bal = HOLogic.mk_binrel @{const_name Orderings.less} + val dest_bal = HOLogic.dest_bin @{const_name Orderings.less} @{typ ennreal} + fun simp_conv _ _ = SOME @{thm ennreal_add_left_cancel_less} +) +\ + +simproc_setup ennreal_eq_cancel + ("(l::ennreal) + m = n" | "(l::ennreal) = m + n") = + \fn phi => fn ctxt => fn ct => Eq_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + +simproc_setup ennreal_le_cancel + ("(l::ennreal) + m \ n" | "(l::ennreal) \ m + n") = + \fn phi => fn ctxt => fn ct => Le_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + +simproc_setup ennreal_less_cancel + ("(l::ennreal) + m < n" | "(l::ennreal) < m + n") = + \fn phi => fn ctxt => fn ct => Less_Ennreal_Cancel.proc ctxt (Thm.term_of ct)\ + instantiation ennreal :: linear_continuum_topology begin @@ -98,7 +269,7 @@ instance proof show "\a b::ennreal. a \ b" - using ennreal_zero_less_one by (auto dest: order.strict_implies_not_eq) + using zero_neq_one by (intro exI) show "\x y::ennreal. x < y \ \z>x. z < y" proof transfer fix x y :: ereal assume "0 \ x" "x < y" @@ -121,14 +292,14 @@ by auto moreover then have "0 \ r" using le_less_trans[OF \0 \ x\ \x < ereal (real_of_rat r)\] by auto - ultimately show "\r. x < (max 0 \ ereal) (real_of_rat r) \ (max 0 \ ereal) (real_of_rat r) < y" + ultimately show "\r. x < (sup 0 \ ereal) (real_of_rat r) \ (sup 0 \ ereal) (real_of_rat r) < y" by (intro exI[of _ r]) (auto simp: max_absorb2) qed lemma enn2ereal_range: "e2ennreal ` {0..} = UNIV" proof - have "\y\0. x = e2ennreal y" for x - by (cases x) auto + by (cases x) (auto simp: e2ennreal_def max_absorb2) then show ?thesis by (auto simp: image_iff Bex_def) qed @@ -138,37 +309,54 @@ lemma ereal_ennreal_cases: obtains b where "0 \ a" "a = enn2ereal b" | "a < 0" - using e2ennreal_inverse[of a, symmetric] by (cases "0 \ a") (auto intro: enn2ereal_nonneg) + using e2ennreal'_inverse[of a, symmetric] by (cases "0 \ a") (auto intro: enn2ereal_nonneg) lemma enn2ereal_Iio: "enn2ereal -` {.. a then {..< e2ennreal a} else {})" using enn2ereal_nonneg by (cases a rule: ereal_ennreal_cases) - (auto simp add: vimage_def set_eq_iff ennreal.enn2ereal_inverse less_ennreal.rep_eq + (auto simp add: vimage_def set_eq_iff ennreal.enn2ereal_inverse less_ennreal.rep_eq e2ennreal_def max_absorb2 intro: le_less_trans less_imp_le) lemma enn2ereal_Ioi: "enn2ereal -` {a <..} = (if 0 \ a then {e2ennreal a <..} else UNIV)" using enn2ereal_nonneg by (cases a rule: ereal_ennreal_cases) - (auto simp add: vimage_def set_eq_iff ennreal.enn2ereal_inverse less_ennreal.rep_eq + (auto simp add: vimage_def set_eq_iff ennreal.enn2ereal_inverse less_ennreal.rep_eq e2ennreal_def max_absorb2 intro: less_le_trans) -lemma continuous_e2ennreal: "continuous_on {0 ..} e2ennreal" - by (rule continuous_onI_mono) - (auto simp add: less_eq_ennreal.abs_eq eq_onp_def enn2ereal_range) +lemma continuous_on_e2ennreal: "continuous_on A e2ennreal" +proof (rule continuous_on_subset) + show "continuous_on ({0..} \ {..0}) e2ennreal" + proof (rule continuous_on_closed_Un) + show "continuous_on {0 ..} e2ennreal" + by (rule continuous_onI_mono) + (auto simp add: less_eq_ennreal.abs_eq eq_onp_def enn2ereal_range) + show "continuous_on {.. 0} e2ennreal" + by (subst continuous_on_cong[OF refl, of _ _ "\_. 0"]) + (auto simp add: e2ennreal_neg continuous_on_const) + qed auto + show "A \ {0..} \ {..0::ereal}" + by auto +qed -lemma continuous_enn2ereal: "continuous_on UNIV enn2ereal" +lemma continuous_at_e2ennreal: "continuous (at x within A) e2ennreal" + by (rule continuous_on_imp_continuous_within[OF continuous_on_e2ennreal, of _ UNIV]) auto + +lemma continuous_on_enn2ereal: "continuous_on UNIV enn2ereal" by (rule continuous_on_generate_topology[OF open_generated_order]) (auto simp add: enn2ereal_Iio enn2ereal_Ioi) +lemma continuous_at_enn2ereal: "continuous (at x within A) enn2ereal" + by (rule continuous_on_imp_continuous_within[OF continuous_on_enn2ereal]) auto + lemma transfer_enn2ereal_continuous_on [transfer_rule]: "rel_fun (op =) (rel_fun (rel_fun op = pcr_ennreal) op =) continuous_on continuous_on" proof - have "continuous_on A f" if "continuous_on A (\x. enn2ereal (f x))" for A and f :: "'a \ ennreal" - using continuous_on_compose2[OF continuous_e2ennreal that] - by (auto simp: ennreal.enn2ereal_inverse subset_eq enn2ereal_nonneg) + using continuous_on_compose2[OF continuous_on_e2ennreal[of "{0..}"] that] + by (auto simp: ennreal.enn2ereal_inverse subset_eq enn2ereal_nonneg e2ennreal_def max_absorb2) moreover have "continuous_on A (\x. enn2ereal (f x))" if "continuous_on A f" for A and f :: "'a \ ennreal" - using continuous_on_compose2[OF continuous_enn2ereal that] by auto + using continuous_on_compose2[OF continuous_on_enn2ereal that] by auto ultimately show ?thesis by (auto simp add: rel_fun_def ennreal.pcr_cr_eq cr_ennreal_def) @@ -180,12 +368,484 @@ by (transfer fixing: A) (auto intro!: tendsto_add_ereal_nonneg simp: continuous_on_def) lemma continuous_on_inverse_ennreal[continuous_intros]: - fixes f :: "_ \ ennreal" + fixes f :: "'a::topological_space \ ennreal" shows "continuous_on A f \ continuous_on A (\x. inverse (f x))" proof (transfer fixing: A) - show "pred_fun (op \ 0) f \ continuous_on A (\x. inverse (f x))" if "continuous_on A f" - for f :: "_ \ ereal" + show "pred_fun (\_. True) (op \ 0) f \ continuous_on A (\x. inverse (f x))" if "continuous_on A f" + for f :: "'a \ ereal" using continuous_on_compose2[OF continuous_on_inverse_ereal that] by (auto simp: subset_eq) qed +instance ennreal :: topological_comm_monoid_add +proof + show "((\x. fst x + snd x) \ a + b) (nhds a \\<^sub>F nhds b)" for a b :: ennreal + using continuous_on_add_ennreal[of UNIV fst snd] + using tendsto_at_iff_tendsto_nhds[symmetric, of "\x::(ennreal \ ennreal). fst x + snd x"] + by (auto simp: continuous_on_eq_continuous_at) + (simp add: isCont_def nhds_prod[symmetric]) +qed + +lemma ennreal_zero_less_top[simp]: "0 < (top::ennreal)" + by transfer (simp add: top_ereal_def) + +lemma ennreal_one_less_top[simp]: "1 < (top::ennreal)" + by transfer (simp add: top_ereal_def) + +lemma ennreal_zero_neq_top[simp]: "0 \ (top::ennreal)" + by transfer (simp add: top_ereal_def) + +lemma ennreal_top_neq_zero[simp]: "(top::ennreal) \ 0" + by transfer (simp add: top_ereal_def) + +lemma ennreal_top_neq_one[simp]: "top \ (1::ennreal)" + by transfer (simp add: top_ereal_def one_ereal_def ereal_max[symmetric] del: ereal_max) + +lemma ennreal_one_neq_top[simp]: "1 \ (top::ennreal)" + by transfer (simp add: top_ereal_def one_ereal_def ereal_max[symmetric] del: ereal_max) + +lemma ennreal_add_less_top[simp]: + fixes a b :: ennreal + shows "a + b < top \ a < top \ b < top" + by transfer (auto simp: top_ereal_def) + +lemma ennreal_add_eq_top[simp]: + fixes a b :: ennreal + shows "a + b = top \ a = top \ b = top" + by transfer (auto simp: top_ereal_def) + +lemma ennreal_setsum_less_top[simp]: + fixes f :: "'a \ ennreal" + shows "finite I \ (\i\I. f i) < top \ (\i\I. f i < top)" + by (induction I rule: finite_induct) auto + +lemma ennreal_setsum_eq_top[simp]: + fixes f :: "'a \ ennreal" + shows "finite I \ (\i\I. f i) = top \ (\i\I. f i = top)" + by (induction I rule: finite_induct) auto + +lemma enn2ereal_eq_top_iff[simp]: "enn2ereal x = \ \ x = top" + by transfer (simp add: top_ereal_def) + +lemma ennreal_top_top: "top - top = (top::ennreal)" + by transfer (auto simp: top_ereal_def max_def) + +lemma ennreal_minus_zero[simp]: "a - (0::ennreal) = a" + by transfer (auto simp: max_def) + +lemma ennreal_add_diff_cancel_right[simp]: + fixes x y z :: ennreal shows "y \ top \ (x + y) - y = x" + apply transfer + subgoal for x y + apply (cases x y rule: ereal2_cases) + apply (auto split: split_max simp: top_ereal_def) + done + done + +lemma ennreal_add_diff_cancel_left[simp]: + fixes x y z :: ennreal shows "y \ top \ (y + x) - y = x" + by (simp add: add.commute) + +lemma + fixes a b :: ennreal + shows "a - b = 0 \ a \ b" + apply transfer + subgoal for a b + apply (cases a b rule: ereal2_cases) + apply (auto simp: not_le max_def split: if_splits) + done + done + +lemma ennreal_minus_cancel: + fixes a b c :: ennreal + shows "c \ top \ a \ c \ b \ c \ c - a = c - b \ a = b" + apply transfer + subgoal for a b c + by (cases a b c rule: ereal3_cases) + (auto simp: top_ereal_def max_def split: if_splits) + done + +lemma enn2ereal_ennreal[simp]: "0 \ x \ enn2ereal (ennreal x) = x" + by transfer (simp add: max_absorb2) + +lemma tendsto_ennrealD: + assumes lim: "((\x. ennreal (f x)) \ ennreal x) F" + assumes *: "\\<^sub>F x in F. 0 \ f x" and x: "0 \ x" + shows "(f \ x) F" + using continuous_on_tendsto_compose[OF continuous_on_enn2ereal lim] + apply simp + apply (subst (asm) tendsto_cong) + using * + apply eventually_elim + apply (auto simp: max_absorb2 \0 \ x\) + done + +lemma tendsto_ennreal_iff[simp]: + "\\<^sub>F x in F. 0 \ f x \ 0 \ x \ ((\x. ennreal (f x)) \ ennreal x) F \ (f \ x) F" + by (auto dest: tendsto_ennrealD) + (auto simp: ennreal_def + intro!: continuous_on_tendsto_compose[OF continuous_on_e2ennreal[of UNIV]] tendsto_max) + +lemma ennreal_zero[simp]: "ennreal 0 = 0" + by (simp add: ennreal_def max.absorb1 zero_ennreal.abs_eq) + +lemma ennreal_plus[simp]: + "0 \ a \ 0 \ b \ ennreal (a + b) = ennreal a + ennreal b" + by (transfer fixing: a b) (auto simp: max_absorb2) + +lemma ennreal_inj[simp]: + "0 \ a \ 0 \ b \ ennreal a = ennreal b \ a = b" + by (transfer fixing: a b) (auto simp: max_absorb2) + +lemma ennreal_le_iff[simp]: "0 \ y \ ennreal x \ ennreal y \ x \ y" + by (auto simp: ennreal_def zero_ereal_def less_eq_ennreal.abs_eq eq_onp_def split: split_max) + +lemma setsum_ennreal[simp]: "(\i. i \ I \ 0 \ f i) \ (\i\I. ennreal (f i)) = ennreal (setsum f I)" + by (induction I rule: infinite_finite_induct) (auto simp: setsum_nonneg) + +lemma sums_ennreal[simp]: "(\i. 0 \ f i) \ 0 \ x \ (\i. ennreal (f i)) sums ennreal x \ f sums x" + unfolding sums_def by (simp add: always_eventually setsum_nonneg) + +lemma summable_suminf_not_top: "(\i. 0 \ f i) \ (\i. ennreal (f i)) \ top \ summable f" + using summable_sums[OF summableI, of "\i. ennreal (f i)"] + by (cases "\i. ennreal (f i)" rule: ennreal_cases) + (auto simp: summable_def) + +lemma suminf_ennreal[simp]: + "(\i. 0 \ f i) \ (\i. ennreal (f i)) \ top \ (\i. ennreal (f i)) = ennreal (\i. f i)" + by (rule sums_unique[symmetric]) (simp add: summable_suminf_not_top suminf_nonneg summable_sums) + +lemma suminf_less_top: "(\i. f i :: ennreal) < top \ f i < top" + using le_less_trans[OF setsum_le_suminf[OF summableI, of "{i}" f]] by simp + +lemma add_top: + fixes x :: "'a::{order_top, ordered_comm_monoid_add}" + shows "0 \ x \ x + top = top" + by (intro top_le add_increasing order_refl) + +lemma top_add: + fixes x :: "'a::{order_top, ordered_comm_monoid_add}" + shows "0 \ x \ top + x = top" + by (intro top_le add_increasing2 order_refl) + +lemma enn2ereal_top: "enn2ereal top = \" + by transfer (simp add: top_ereal_def) + +lemma e2ennreal_infty: "e2ennreal \ = top" + by (simp add: top_ennreal.abs_eq top_ereal_def) + +lemma sup_const_add_ennreal: + fixes a b c :: "ennreal" + shows "sup (c + a) (c + b) = c + sup a b" + apply transfer + subgoal for a b c + apply (cases a b c rule: ereal3_cases) + apply (auto simp: ereal_max[symmetric] simp del: ereal_max) + apply (auto simp: top_ereal_def[symmetric] sup_ereal_def[symmetric] + simp del: sup_ereal_def) + apply (auto simp add: top_ereal_def) + done + done + +lemma bot_ennreal: "bot = (0::ennreal)" + by transfer rule + +lemma le_lfp: "mono f \ x \ lfp f \ f x \ lfp f" + by (subst lfp_unfold) (auto dest: monoD) + +lemma lfp_transfer: + assumes \: "sup_continuous \" and f: "sup_continuous f" and mg: "mono g" + assumes bot: "\ bot \ lfp g" and eq: "\x. x \ lfp f \ \ (f x) = g (\ x)" + shows "\ (lfp f) = lfp g" +proof (rule antisym) + note mf = sup_continuous_mono[OF f] + have f_le_lfp: "(f ^^ i) bot \ lfp f" for i + by (induction i) (auto intro: le_lfp mf) + + have "\ ((f ^^ i) bot) \ lfp g" for i + by (induction i) (auto simp: bot eq f_le_lfp intro!: le_lfp mg) + then show "\ (lfp f) \ lfp g" + unfolding sup_continuous_lfp[OF f] + by (subst \[THEN sup_continuousD]) + (auto intro!: mono_funpow sup_continuous_mono[OF f] SUP_least) + + show "lfp g \ \ (lfp f)" + by (rule lfp_lowerbound) (simp add: eq[symmetric] lfp_unfold[OF mf, symmetric]) +qed + +lemma sup_continuous_applyD: "sup_continuous f \ sup_continuous (\x. f x h)" + using sup_continuous_apply[THEN sup_continuous_compose] . + +lemma INF_ennreal_add_const: + fixes f g :: "nat \ ennreal" + shows "(INF i. f i + c) = (INF i. f i) + c" + using continuous_at_Inf_mono[of "\x. x + c" "f`UNIV"] + using continuous_add[of "at_right (Inf (range f))", of "\x. x" "\x. c"] + by (auto simp: mono_def) + +lemma INF_ennreal_const_add: + fixes f g :: "nat \ ennreal" + shows "(INF i. c + f i) = c + (INF i. f i)" + using INF_ennreal_add_const[of f c] by (simp add: ac_simps) + +lemma sup_continuous_e2ennreal[order_continuous_intros]: + assumes f: "sup_continuous f" shows "sup_continuous (\x. e2ennreal (f x))" + apply (rule sup_continuous_compose[OF _ f]) + apply (rule continuous_at_left_imp_sup_continuous) + apply (auto simp: mono_def e2ennreal_mono continuous_at_e2ennreal) + done + +lemma sup_continuous_enn2ereal[order_continuous_intros]: + assumes f: "sup_continuous f" shows "sup_continuous (\x. enn2ereal (f x))" + apply (rule sup_continuous_compose[OF _ f]) + apply (rule continuous_at_left_imp_sup_continuous) + apply (simp_all add: mono_def less_eq_ennreal.rep_eq continuous_at_enn2ereal) + done + +lemma ennreal_1[simp]: "ennreal 1 = 1" + by transfer (simp add: max_absorb2) + +lemma ennreal_of_nat_eq_real_of_nat: "of_nat i = ennreal (of_nat i)" + by (induction i) simp_all + +lemma ennreal_SUP_of_nat_eq_top: "(SUP x. of_nat x :: ennreal) = top" +proof (intro antisym top_greatest le_SUP_iff[THEN iffD2] allI impI) + fix y :: ennreal assume "y < top" + then obtain r where "y = ennreal r" + by (cases y rule: ennreal_cases) auto + then show "\i\UNIV. y < of_nat i" + using ex_less_of_nat[of "max 1 r"] zero_less_one + by (auto simp: ennreal_of_nat_eq_real_of_nat ennreal_def less_ennreal.abs_eq eq_onp_def max.absorb2 + dest!: one_less_of_natD intro: less_trans) +qed + +lemma ennreal_SUP_eq_top: + fixes f :: "'a \ ennreal" + assumes "\n. \i\I. of_nat n \ f i" + shows "(SUP i : I. f i) = top" +proof - + have "(SUP x. of_nat x :: ennreal) \ (SUP i : I. f i)" + using assms by (auto intro!: SUP_least intro: SUP_upper2) + then show ?thesis + by (auto simp: ennreal_SUP_of_nat_eq_top top_unique) +qed + +lemma sup_continuous_SUP[order_continuous_intros]: + fixes M :: "_ \ _ \ 'a::complete_lattice" + assumes M: "\i. i \ I \ sup_continuous (M i)" + shows "sup_continuous (SUP i:I. M i)" + unfolding sup_continuous_def by (auto simp add: sup_continuousD[OF M] intro: SUP_commute) + +lemma sup_continuous_apply_SUP[order_continuous_intros]: + fixes M :: "_ \ _ \ 'a::complete_lattice" + shows "(\i. i \ I \ sup_continuous (M i)) \ sup_continuous (\x. SUP i:I. M i x)" + unfolding SUP_apply[symmetric] by (rule sup_continuous_SUP) + +lemma sup_continuous_lfp'[order_continuous_intros]: + assumes 1: "sup_continuous f" + assumes 2: "\g. sup_continuous g \ sup_continuous (f g)" + shows "sup_continuous (lfp f)" +proof - + have "sup_continuous ((f ^^ i) bot)" for i + proof (induction i) + case (Suc i) then show ?case + by (auto intro!: 2) + qed (simp add: bot_fun_def sup_continuous_const) + then show ?thesis + unfolding sup_continuous_lfp[OF 1] by (intro order_continuous_intros) +qed + +lemma sup_continuous_lfp''[order_continuous_intros]: + assumes 1: "\s. sup_continuous (f s)" + assumes 2: "\g. sup_continuous g \ sup_continuous (\s. f s (g s))" + shows "sup_continuous (\x. lfp (f x))" +proof - + have "sup_continuous (\x. (f x ^^ i) bot)" for i + proof (induction i) + case (Suc i) then show ?case + by (auto intro!: 2) + qed (simp add: bot_fun_def sup_continuous_const) + then show ?thesis + unfolding sup_continuous_lfp[OF 1] by (intro order_continuous_intros) +qed + +lemma ennreal_INF_const_minus: + fixes f :: "'a \ ennreal" + shows "I \ {} \ (SUP x:I. c - f x) = c - (INF x:I. f x)" + by (transfer fixing: I) + (simp add: sup_max[symmetric] SUP_sup_const1 SUP_ereal_minus_right del: sup_ereal_def) + +lemma ennreal_diff_add_assoc: + fixes a b c :: ennreal + shows "a \ b \ c + b - a = c + (b - a)" + apply transfer + subgoal for a b c + apply (cases a b c rule: ereal3_cases) + apply (auto simp: field_simps max_absorb2) + done + done + +lemma ennreal_top_minus[simp]: + fixes c :: ennreal + shows "top - c = top" + by transfer (auto simp: top_ereal_def max_absorb2) + +lemma le_ennreal_iff: + "0 \ r \ x \ ennreal r \ (\q\0. x = ennreal q \ q \ r)" + apply (transfer fixing: r) + subgoal for x + by (cases x) (auto simp: max_absorb2 cong: conj_cong) + done + +lemma ennreal_minus: "0 \ q \ q \ r \ ennreal r - ennreal q = ennreal (r - q)" + by transfer (simp add: max_absorb2) + +lemma ennreal_tendsto_const_minus: + fixes g :: "'a \ ennreal" + assumes ae: "\\<^sub>F x in F. g x \ c" + assumes g: "((\x. c - g x) \ 0) F" + shows "(g \ c) F" +proof (cases c rule: ennreal_cases) + case top with tendsto_unique[OF _ g, of "top"] show ?thesis + by (cases "F = bot") auto +next + case (real r) + then have "\x. \q\0. g x \ c \ (g x = ennreal q \ q \ r)" + by (auto simp: le_ennreal_iff) + then obtain f where *: "\x. g x \ c \ 0 \ f x" "\x. g x \ c \ g x = ennreal (f x)" "\x. g x \ c \ f x \ r" + by metis + from ae have ae2: "\\<^sub>F x in F. c - g x = ennreal (r - f x) \ f x \ r \ g x = ennreal (f x) \ 0 \ f x" + proof eventually_elim + fix x assume "g x \ c" with *[of x] \0 \ r\ show "c - g x = ennreal (r - f x) \ f x \ r \ g x = ennreal (f x) \ 0 \ f x" + by (auto simp: real ennreal_minus) + qed + with g have "((\x. ennreal (r - f x)) \ ennreal 0) F" + by (auto simp add: tendsto_cong eventually_conj_iff) + with ae2 have "((\x. r - f x) \ 0) F" + by (subst (asm) tendsto_ennreal_iff) (auto elim: eventually_mono) + then have "(f \ r) F" + by (rule Lim_transform2[OF tendsto_const]) + with ae2 have "((\x. ennreal (f x)) \ ennreal r) F" + by (subst tendsto_ennreal_iff) (auto elim: eventually_mono simp: real) + with ae2 show ?thesis + by (auto simp: real tendsto_cong eventually_conj_iff) +qed + +lemma ereal_add_diff_cancel: + fixes a b :: ereal + shows "\b\ \ \ \ (a + b) - b = a" + by (cases a b rule: ereal2_cases) auto + +lemma ennreal_add_diff_cancel: + fixes a b :: ennreal + shows "b \ \ \ (a + b) - b = a" + unfolding infinity_ennreal_def + by transfer (simp add: max_absorb2 top_ereal_def ereal_add_diff_cancel) + +lemma ennreal_mult_eq_top_iff: + fixes a b :: ennreal + shows "a * b = top \ (a = top \ b \ 0) \ (b = top \ a \ 0)" + by transfer (auto simp: top_ereal_def) + +lemma ennreal_top_eq_mult_iff: + fixes a b :: ennreal + shows "top = a * b \ (a = top \ b \ 0) \ (b = top \ a \ 0)" + using ennreal_mult_eq_top_iff[of a b] by auto + +lemma ennreal_mult: "0 \ a \ 0 \ b \ ennreal (a * b) = ennreal a * ennreal b" + by transfer (simp add: max_absorb2) + +lemma setsum_enn2ereal[simp]: "(\i. i \ I \ 0 \ f i) \ (\i\I. enn2ereal (f i)) = enn2ereal (setsum f I)" + by (induction I rule: infinite_finite_induct) (auto simp: setsum_nonneg zero_ennreal.rep_eq plus_ennreal.rep_eq) + +lemma e2ennreal_enn2ereal[simp]: "e2ennreal (enn2ereal x) = x" + by (simp add: e2ennreal_def max_absorb2 enn2ereal_nonneg ennreal.enn2ereal_inverse) + +lemma tendsto_enn2ereal_iff[simp]: "((\i. enn2ereal (f i)) \ enn2ereal x) F \ (f \ x) F" + using continuous_on_enn2ereal[THEN continuous_on_tendsto_compose, of f x F] + continuous_on_e2ennreal[THEN continuous_on_tendsto_compose, of "\x. enn2ereal (f x)" "enn2ereal x" F UNIV] + by auto + +lemma sums_enn2ereal[simp]: "(\i. enn2ereal (f i)) sums enn2ereal x \ f sums x" + unfolding sums_def by (simp add: always_eventually setsum_nonneg setsum_enn2ereal) + +lemma suminf_enn2real[simp]: "(\i. enn2ereal (f i)) = enn2ereal (suminf f)" + by (rule sums_unique[symmetric]) (simp add: summable_sums) + +lemma pcr_ennreal_enn2ereal[simp]: "pcr_ennreal (enn2ereal x) x" + by (simp add: ennreal.pcr_cr_eq cr_ennreal_def) + +lemma rel_fun_eq_pcr_ennreal: "rel_fun op = pcr_ennreal f g \ f = enn2ereal \ g" + by (auto simp: rel_fun_def ennreal.pcr_cr_eq cr_ennreal_def) + +lemma transfer_e2ennreal_suminf [transfer_rule]: "rel_fun (rel_fun op = pcr_ennreal) pcr_ennreal suminf suminf" + by (auto simp: rel_funI rel_fun_eq_pcr_ennreal comp_def) + +lemma ennreal_suminf_cmult[simp]: "(\i. r * f i) = r * (\i. f i::ennreal)" + by transfer (auto intro!: suminf_cmult_ereal) + +lemma ennreal_suminf_SUP_eq_directed: + fixes f :: "'a \ nat \ ennreal" + assumes *: "\N i j. i \ I \ j \ I \ finite N \ \k\I. \n\N. f i n \ f k n \ f j n \ f k n" + shows "(\n. SUP i:I. f i n) = (SUP i:I. \n. f i n)" +proof cases + assume "I \ {}" + then obtain i where "i \ I" by auto + from * show ?thesis + by (transfer fixing: I) + (auto simp: max_absorb2 SUP_upper2[OF \i \ I\] suminf_nonneg summable_ereal_pos \I \ {}\ + intro!: suminf_SUP_eq_directed) +qed (simp add: bot_ennreal) + +lemma ennreal_eq_zero_iff[simp]: "0 \ x \ ennreal x = 0 \ x = 0" + by transfer (auto simp: max_absorb2) + +lemma ennreal_neq_top[simp]: "ennreal r \ top" + by transfer (simp add: top_ereal_def zero_ereal_def ereal_max[symmetric] del: ereal_max) + +lemma ennreal_of_nat_neq_top[simp]: "of_nat i \ (top::ennreal)" + by (induction i) auto + +lemma ennreal_suminf_neq_top: "summable f \ (\i. 0 \ f i) \ (\i. ennreal (f i)) \ top" + using sums_ennreal[of f "suminf f"] + by (simp add: suminf_nonneg sums_unique[symmetric] summable_sums_iff[symmetric] del: sums_ennreal) + +instance ennreal :: semiring_char_0 +proof (standard, safe intro!: linorder_injI) + have *: "1 + of_nat k \ (0::ennreal)" for k + using add_pos_nonneg[OF zero_less_one, of "of_nat k :: ennreal"] by auto + fix x y :: nat assume "x < y" "of_nat x = (of_nat y::ennreal)" then show False + by (auto simp add: less_iff_Suc_add *) +qed + +lemma ennreal_suminf_lessD: "(\i. f i :: ennreal) < x \ f i < x" + using le_less_trans[OF setsum_le_suminf[OF summableI, of "{i}" f]] by simp + +lemma ennreal_less_top[simp]: "ennreal x < top" + by transfer (simp add: top_ereal_def max_def) + +lemma ennreal_le_epsilon: + "(\e::real. y < top \ 0 < e \ x \ y + ennreal e) \ x \ y" + apply (cases y rule: ennreal_cases) + apply (cases x rule: ennreal_cases) + apply (auto simp del: ennreal_plus simp add: top_unique ennreal_plus[symmetric] + intro: zero_less_one field_le_epsilon) + done + +lemma ennreal_less_zero_iff[simp]: "0 < ennreal x \ 0 < x" + by transfer (auto simp: max_def) + +lemma suminf_ennreal_eq: + "(\i. 0 \ f i) \ f sums x \ (\i. ennreal (f i)) = ennreal x" + using suminf_nonneg[of f] sums_unique[of f x] + by (intro sums_unique[symmetric]) (auto simp: summable_sums_iff) + +lemma transfer_e2ennreal_sumset [transfer_rule]: + "rel_fun (rel_fun op = pcr_ennreal) (rel_fun op = pcr_ennreal) setsum setsum" + by (auto intro!: rel_funI simp: rel_fun_eq_pcr_ennreal comp_def) + +lemma ennreal_suminf_bound_add: + fixes f :: "nat \ ennreal" + shows "(\N. (\n x) \ suminf f + y \ x" + by transfer (auto intro!: suminf_bound_add) + end diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Library/Extended_Real.thy Fri Feb 19 13:40:50 2016 +0100 @@ -40,7 +40,7 @@ qed lemma continuous_at_left_imp_sup_continuous: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology} \ 'b::{complete_linorder, linorder_topology}" assumes "mono f" "\x. continuous (at_left x) f" shows "sup_continuous f" unfolding sup_continuous_def @@ -50,7 +50,8 @@ qed lemma sup_continuous_at_left: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology, first_countable_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \ + 'b::{complete_linorder, linorder_topology}" assumes f: "sup_continuous f" shows "continuous (at_left x) f" proof cases @@ -71,13 +72,14 @@ qed lemma sup_continuous_iff_at_left: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology, first_countable_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \ + 'b::{complete_linorder, linorder_topology}" shows "sup_continuous f \ (\x. continuous (at_left x) f) \ mono f" using sup_continuous_at_left[of f] continuous_at_left_imp_sup_continuous[of f] sup_continuous_mono[of f] by auto lemma continuous_at_right_imp_inf_continuous: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology} \ 'b::{complete_linorder, linorder_topology}" assumes "mono f" "\x. continuous (at_right x) f" shows "inf_continuous f" unfolding inf_continuous_def @@ -87,7 +89,8 @@ qed lemma inf_continuous_at_right: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology, first_countable_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \ + 'b::{complete_linorder, linorder_topology}" assumes f: "inf_continuous f" shows "continuous (at_right x) f" proof cases @@ -108,7 +111,8 @@ qed lemma inf_continuous_iff_at_right: - fixes f :: "'a \ 'a::{complete_linorder, linorder_topology, first_countable_topology}" + fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} \ + 'b::{complete_linorder, linorder_topology}" shows "inf_continuous f \ (\x. continuous (at_right x) f) \ mono f" using inf_continuous_at_right[of f] continuous_at_right_imp_inf_continuous[of f] inf_continuous_mono[of f] by auto diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Library/Multiset.thy Fri Feb 19 13:40:50 2016 +0100 @@ -305,6 +305,9 @@ interpretation subset_mset: ordered_cancel_comm_monoid_diff "op +" 0 "op \#" "op <#" "op -" by standard (simp, fact mset_le_exists_conv) +declare subset_mset.zero_order[simp del] + -- \this removes some simp rules not in the usual order for multisets\ + lemma mset_le_mono_add_right_cancel [simp]: "(A::'a multiset) + C \# B + C \ A \# B" by (fact subset_mset.add_le_cancel_right) @@ -382,7 +385,7 @@ by (fact subset_mset.add_less_imp_less_right) lemma mset_less_empty_nonempty: "{#} <# S \ S \ {#}" - by (auto simp: subset_mset_def subseteq_mset_def) + by (fact subset_mset.zero_less_iff_neq_zero) lemma mset_less_diff_self: "c \# B \ B - {#c#} <# B" by (auto simp: subset_mset_def subseteq_mset_def multiset_eq_iff) diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/NSA/HyperNat.thy --- a/src/HOL/NSA/HyperNat.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/NSA/HyperNat.thy Fri Feb 19 13:40:50 2016 +0100 @@ -2,7 +2,7 @@ Author : Jacques D. Fleuriot Copyright : 1998 University of Cambridge -Converted to Isar and polished by lcp +Converted to Isar and polished by lcp *) section\Hypernatural numbers\ @@ -108,7 +108,7 @@ by transfer (rule le_add2) lemma hypnat_add_one_self_less [simp]: "(x::hypnat) < x + (1::hypnat)" -by (insert add_strict_left_mono [OF zero_less_one], auto) + by (fact less_add_one) lemma hypnat_neq0_conv [iff]: "!!n. (n \ 0) = (0 < (n::hypnat))" by transfer (rule neq0_conv) @@ -117,14 +117,10 @@ by (auto simp add: linorder_not_less [symmetric]) lemma hypnat_gt_zero_iff2: "(0 < n) = (\m. n = m + (1::hypnat))" -apply safe - apply (rule_tac x = "n - (1::hypnat) " in exI) - apply (simp add: hypnat_gt_zero_iff) -apply (insert add_le_less_mono [OF _ zero_less_one, of 0], auto) -done + by (auto intro!: add_nonneg_pos exI[of _ "n - 1"] simp: hypnat_gt_zero_iff) lemma hypnat_add_self_not_less: "~ (x + y < (x::hypnat))" -by (simp add: linorder_not_le [symmetric] add.commute [of x]) +by (simp add: linorder_not_le [symmetric] add.commute [of x]) lemma hypnat_diff_split: "P(a - b::hypnat) = ((a P 0) & (ALL d. a = b + d --> P d))" @@ -132,12 +128,12 @@ proof (cases "aProperties of the set of embedded natural numbers\ @@ -163,10 +159,10 @@ lemma of_nat_eq_add [rule_format]: "\d::hypnat. of_nat m = of_nat n + d --> d \ range of_nat" -apply (induct n) -apply (auto simp add: add.assoc) -apply (case_tac x) -apply (auto simp add: add.commute [of 1]) +apply (induct n) +apply (auto simp add: add.assoc) +apply (case_tac x) +apply (auto simp add: add.commute [of 1]) done lemma Nats_diff [simp]: "[|a \ Nats; b \ Nats|] ==> (a-b :: hypnat) \ Nats" @@ -337,7 +333,7 @@ done -subsubsection\Alternative Characterization of @{term HNatInfinite} using +subsubsection\Alternative Characterization of @{term HNatInfinite} using Free Ultrafilter\ lemma HNatInfinite_FreeUltrafilterNat: @@ -353,7 +349,7 @@ lemma HNatInfinite_FreeUltrafilterNat_iff: "(star_n X \ HNatInfinite) = (\u. eventually (\n. u < X n) FreeUltrafilterNat)" -by (rule iffI [OF HNatInfinite_FreeUltrafilterNat +by (rule iffI [OF HNatInfinite_FreeUltrafilterNat FreeUltrafilterNat_HNatInfinite]) subsection \Embedding of the Hypernaturals into other types\ diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/NSA/StarDef.thy --- a/src/HOL/NSA/StarDef.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/NSA/StarDef.thy Fri Feb 19 13:40:50 2016 +0100 @@ -987,7 +987,8 @@ lemma star_of_of_int [simp]: "star_of (of_int z) = of_int z" by transfer (rule refl) -instance star :: (semiring_char_0) semiring_char_0 proof +instance star :: (semiring_char_0) semiring_char_0 +proof have "inj (star_of :: 'a \ 'a star)" by (rule injI) simp then have "inj (star_of \ of_nat :: nat \ 'a star)" using inj_of_nat by (rule inj_comp) then show "inj (of_nat :: nat \ 'a star)" by (simp add: comp_def) diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Nat.thy --- a/src/HOL/Nat.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Nat.thy Fri Feb 19 13:40:50 2016 +0100 @@ -752,6 +752,10 @@ instance nat :: dioid proof qed (rule nat_le_iff_add) +declare le0[simp del] -- \This is now @{thm zero_le}\ +declare le_0_eq[simp del] -- \This is now @{thm le_zero_eq}\ +declare not_less0[simp del] -- \This is now @{thm not_less_zero}\ +declare not_gr0[simp del] -- \This is now @{thm not_gr_zero}\ instance nat :: ordered_cancel_comm_monoid_add proof qed diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Quotient_Examples/Int_Pow.thy --- a/src/HOL/Quotient_Examples/Int_Pow.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Quotient_Examples/Int_Pow.thy Fri Feb 19 13:40:50 2016 +0100 @@ -5,12 +5,12 @@ theory Int_Pow imports Main "~~/src/HOL/Algebra/Group" -begin +begin (* This file demonstrates how to restore Lifting/Transfer enviromenent. - We want to define int_pow (a power with an integer exponent) by directly accessing + We want to define int_pow (a power with an integer exponent) by directly accessing the representation type "nat * nat" that was used to define integers. *) @@ -19,7 +19,7 @@ (* first some additional lemmas that are missing in monoid *) -lemma Units_nat_pow_Units [intro, simp]: +lemma Units_nat_pow_Units [intro, simp]: "a \ Units G \ a (^) (c :: nat) \ Units G" by (induct c) auto lemma Units_r_cancel [simp]: @@ -47,13 +47,13 @@ with G show ?thesis by (simp del: Units_l_inv) qed -lemma mult_same_comm: - assumes [simp, intro]: "a \ Units G" +lemma mult_same_comm: + assumes [simp, intro]: "a \ Units G" shows "a (^) (m::nat) \ inv (a (^) (n::nat)) = inv (a (^) n) \ a (^) m" proof (cases "m\n") have [simp]: "a \ carrier G" using `a \ _` by (rule Units_closed) case True - then obtain k where *:"m = k + n" and **:"m = n + k" by (metis Nat.le_iff_add add.commute) + then obtain k where *:"m = k + n" and **:"m = n + k" by (metis le_iff_add add.commute) have "a (^) (m::nat) \ inv (a (^) (n::nat)) = a (^) k" using * by (auto simp add: nat_pow_mult[symmetric] m_assoc) also have "\ = inv (a (^) n) \ a (^) m" @@ -62,8 +62,8 @@ next have [simp]: "a \ carrier G" using `a \ _` by (rule Units_closed) case False - then obtain k where *:"n = k + m" and **:"n = m + k" - by (metis Nat.le_iff_add add.commute nat_le_linear) + then obtain k where *:"n = k + m" and **:"n = m + k" + by (metis le_iff_add add.commute nat_le_linear) have "a (^) (m::nat) \ inv (a (^) (n::nat)) = inv(a (^) k)" using * by (auto simp add: nat_pow_mult[symmetric] m_assoc[symmetric] inv_mult_units) also have "\ = inv (a (^) n) \ a (^) m" @@ -71,7 +71,7 @@ finally show ?thesis . qed -lemma mult_inv_same_comm: +lemma mult_inv_same_comm: "a \ Units G \ inv (a (^) (m::nat)) \ inv (a (^) (n::nat)) = inv (a (^) n) \ inv (a (^) m)" by (simp add: inv_mult_units[symmetric] nat_pow_mult ac_simps Units_closed) @@ -86,21 +86,21 @@ proof(cases "b\c") have [simp]: "a \ carrier G" using `a \ _` by (rule Units_closed) case True - then obtain n where "b = n + c" by (metis Nat.le_iff_add add.commute) + then obtain n where "b = n + c" by (metis le_iff_add add.commute) then have "d = n + e" using eq by arith - from `b = _` have "a (^) b \ inv (a (^) c) = a (^) n" + from `b = _` have "a (^) b \ inv (a (^) c) = a (^) n" by (auto simp add: nat_pow_mult[symmetric] m_assoc) - also from `d = _` have "\ = a (^) d \ inv (a (^) e)" + also from `d = _` have "\ = a (^) d \ inv (a (^) e)" by (auto simp add: nat_pow_mult[symmetric] m_assoc) finally show ?thesis . next have [simp]: "a \ carrier G" using `a \ _` by (rule Units_closed) case False - then obtain n where "c = n + b" by (metis Nat.le_iff_add add.commute nat_le_linear) + then obtain n where "c = n + b" by (metis le_iff_add add.commute nat_le_linear) then have "e = n + d" using eq by arith - from `c = _` have "a (^) b \ inv (a (^) c) = inv (a (^) n)" + from `c = _` have "a (^) b \ inv (a (^) c) = inv (a (^) n)" by (auto simp add: nat_pow_mult[symmetric] m_assoc[symmetric] inv_mult_units) - also from `e = _` have "\ = a (^) d \ inv (a (^) e)" + also from `e = _` have "\ = a (^) d \ inv (a (^) e)" by (auto simp add: nat_pow_mult[symmetric] m_assoc[symmetric] inv_mult_units) finally show ?thesis . qed @@ -110,12 +110,12 @@ it doesn't contain a test z < 0 when a (^) z is being defined. *) -lift_definition int_pow :: "('a, 'm) monoid_scheme \ 'a \ int \ 'a" is - "\G a (n1, n2). if a \ Units G \ monoid G then (a (^)\<^bsub>G\<^esub> n1) \\<^bsub>G\<^esub> (inv\<^bsub>G\<^esub> (a (^)\<^bsub>G\<^esub> n2)) else \\<^bsub>G\<^esub>" +lift_definition int_pow :: "('a, 'm) monoid_scheme \ 'a \ int \ 'a" is + "\G a (n1, n2). if a \ Units G \ monoid G then (a (^)\<^bsub>G\<^esub> n1) \\<^bsub>G\<^esub> (inv\<^bsub>G\<^esub> (a (^)\<^bsub>G\<^esub> n2)) else \\<^bsub>G\<^esub>" unfolding intrel_def by (auto intro: monoid.int_pow_rsp) (* - Thus, for example, the proof of distributivity of int_pow and addition + Thus, for example, the proof of distributivity of int_pow and addition doesn't require a substantial number of case distinctions. *) @@ -125,7 +125,7 @@ proof - { fix k l m :: nat - have "a (^) l \ (inv (a (^) m) \ inv (a (^) k)) = (a (^) l \ inv (a (^) k)) \ inv (a (^) m)" + have "a (^) l \ (inv (a (^) m) \ inv (a (^) k)) = (a (^) l \ inv (a (^) k)) \ inv (a (^) m)" (is "?lhs = _") by (simp add: mult_inv_same_comm m_assoc Units_closed) also have "\ = (inv (a (^) k) \ a (^) l) \ inv (a (^) m)" diff -r ace69956d018 -r 85ed00c1fe7c src/HOL/Rings.thy --- a/src/HOL/Rings.thy Fri Feb 12 16:09:07 2016 +0100 +++ b/src/HOL/Rings.thy Fri Feb 19 13:40:50 2016 +0100 @@ -1312,7 +1312,7 @@ lemma mult_nonneg_nonpos2: "0 \ a \ b \ 0 \ b * a \ 0" by (drule mult_right_mono [of b 0], auto) -lemma split_mult_neg_le: "(0 \ a & b \ 0) | (a \ 0 & 0 \ b) \ a * b \ 0" +lemma split_mult_neg_le: "(0 \ a \ b \ 0) \ (a \ 0 \ 0 \ b) \ a * b \ 0" by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2) end @@ -1735,17 +1735,51 @@ end -class linordered_semidom = semidom + linordered_comm_semiring_strict + +class zero_less_one = order + zero + one + assumes zero_less_one [simp]: "0 < 1" + +class linordered_nonzero_semiring = ordered_comm_semiring + monoid_mult + linorder + zero_less_one +begin + +subclass zero_neq_one + proof qed (insert zero_less_one, blast) + +subclass comm_semiring_1 + proof qed (rule mult_1_left) + +lemma zero_le_one [simp]: "0 \ 1" +by (rule zero_less_one [THEN less_imp_le]) + +lemma not_one_le_zero [simp]: "\ 1 \ 0" +by (simp add: not_le) + +lemma not_one_less_zero [simp]: "\ 1 < 0" +by (simp add: not_less) + +lemma mult_left_le: "c \ 1 \ 0 \ a \ a * c \ a" + using mult_left_mono[of c 1 a] by simp + +lemma mult_le_one: "a \ 1 \ 0 \ b \ b \ 1 \ a * b \ 1" + using mult_mono[of a 1 b 1] by simp + +lemma zero_less_two: "0 < 1 + 1" + using add_pos_pos[OF zero_less_one zero_less_one] . + +end + +class linordered_semidom = semidom + linordered_comm_semiring_strict + zero_less_one + assumes le_add_diff_inverse2 [simp]: "b \ a \ a - b + b = a" begin +subclass linordered_nonzero_semiring + proof qed + text \Addition is the inverse of subtraction.\ lemma le_add_diff_inverse [simp]: "b \ a \ b + (a - b) = a" by (frule le_add_diff_inverse2) (simp add: add.commute) -lemma add_diff_inverse: "~ a b + (a - b) = a" +lemma add_diff_inverse: "\ a < b \ b + (a - b) = a" by simp lemma add_le_imp_le_diff: @@ -1771,36 +1805,14 @@ by (simp add: add.commute diff_diff_add) qed -lemma pos_add_strict: - shows "0 < a \ b < c \ b < a + c" - using add_strict_mono [of 0 a b c] by simp - -lemma zero_le_one [simp]: "0 \ 1" -by (rule zero_less_one [THEN less_imp_le]) - -lemma not_one_le_zero [simp]: "\ 1 \ 0" -by (simp add: not_le) - -lemma not_one_less_zero [simp]: "\ 1 < 0" -by (simp add: not_less) - lemma less_1_mult: - assumes "1 < m" and "1 < n" - shows "1 < m * n" - using assms mult_strict_mono [of 1 m 1 n] - by (simp add: less_trans [OF zero_less_one]) - -lemma mult_left_le: "c \ 1 \ 0 \ a \ a * c \ a" - using mult_left_mono[of c 1 a] by simp - -lemma mult_le_one: "a \ 1 \ 0 \ b \ b \ 1 \ a * b \ 1" - using mult_mono[of a 1 b 1] by simp + "1 < m \ 1 < n \ 1 < m * n" + using mult_strict_mono [of 1 m 1 n] by (simp add: less_trans [OF zero_less_one]) end -class linordered_idom = comm_ring_1 + - linordered_comm_semiring_strict + ordered_ab_group_add + - abs_if + sgn_if +class linordered_idom = + comm_ring_1 + linordered_comm_semiring_strict + ordered_ab_group_add + abs_if + sgn_if begin subclass linordered_semiring_1_strict .. @@ -1962,9 +1974,6 @@ thus ?thesis by simp qed -lemma zero_less_two: "0 < 1 + 1" -by (blast intro: less_trans zero_less_one less_add_one) - end context linordered_idom