# HG changeset patch # User nipkow # Date 1251720582 -7200 # Node ID 341c83339aebd6fd411dac0b13c94f77d92ba89a # Parent 375db037f4d26660a8b8ec9a78586b34b83c3613 tuned the simp rules for Int involving insert and intervals. diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Algebra/Divisibility.thy --- a/src/HOL/Algebra/Divisibility.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Algebra/Divisibility.thy Mon Aug 31 14:09:42 2009 +0200 @@ -2656,25 +2656,7 @@ shows "(x \ carrier G \ x gcdof a b) = greatest (division_rel G) x (Lower (division_rel G) {a, b})" unfolding isgcd_def greatest_def Lower_def elem_def -proof (simp, safe) - fix xa - assume r1[rule_format]: "\x. (x = a \ x = b) \ x \ carrier G \ xa divides x" - assume r2[rule_format]: "\y\carrier G. y divides a \ y divides b \ y divides x" - - assume "xa \ carrier G" "x divides a" "x divides b" - with carr - show "xa divides x" - by (fast intro: r1 r2) -next - fix a' y - assume r1[rule_format]: - "\xa\{l. \x. (x = a \ x = b) \ x \ carrier G \ l divides x} \ carrier G. - xa divides x" - assume "y \ carrier G" "y divides a" "y divides b" - with carr - show "y divides x" - by (fast intro: r1) -qed (simp, simp) +by auto lemma lcmof_leastUpper: fixes G (structure) @@ -2682,25 +2664,7 @@ shows "(x \ carrier G \ x lcmof a b) = least (division_rel G) x (Upper (division_rel G) {a, b})" unfolding islcm_def least_def Upper_def elem_def -proof (simp, safe) - fix xa - assume r1[rule_format]: "\x. (x = a \ x = b) \ x \ carrier G \ x divides xa" - assume r2[rule_format]: "\y\carrier G. a divides y \ b divides y \ x divides y" - - assume "xa \ carrier G" "a divides x" "b divides x" - with carr - show "x divides xa" - by (fast intro: r1 r2) -next - fix a' y - assume r1[rule_format]: - "\xa\{l. \x. (x = a \ x = b) \ x \ carrier G \ x divides l} \ carrier G. - x divides xa" - assume "y \ carrier G" "a divides y" "b divides y" - with carr - show "x divides y" - by (fast intro: r1) -qed (simp, simp) +by auto lemma somegcd_meet: fixes G (structure) diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Algebra/UnivPoly.thy --- a/src/HOL/Algebra/UnivPoly.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Algebra/UnivPoly.thy Mon Aug 31 14:09:42 2009 +0200 @@ -592,15 +592,14 @@ proof (cases "n = k") case True then have "\ = (\i \ {.. {n}. ?s i)" - by (simp cong: R.finsum_cong add: ivl_disj_int_singleton Pi_def) + by (simp cong: R.finsum_cong add: Pi_def) also from True have "... = (\i \ {..k}. ?s i)" by (simp only: ivl_disj_un_singleton) finally show ?thesis . next case False with n_le_k have n_less_k: "n < k" by arith with neq have "\ = (\i \ {.. {n}. ?s i)" - by (simp add: R.finsum_Un_disjoint f1 f2 - ivl_disj_int_singleton Pi_def del: Un_insert_right) + by (simp add: R.finsum_Un_disjoint f1 f2 Pi_def del: Un_insert_right) also have "... = (\i \ {..n}. ?s i)" by (simp only: ivl_disj_un_singleton) also from n_less_k neq have "... = (\i \ {..n} \ {n<..k}. ?s i)" @@ -939,8 +938,7 @@ also have "...= (\i \ {deg R p} \ {deg R p <.. deg R p + deg R q}. ?s i)" by (simp only: ivl_disj_un_singleton) also have "... = coeff P p (deg R p) \ coeff P q (deg R q)" - by (simp cong: R.finsum_cong - add: ivl_disj_int_singleton deg_aboveD R Pi_def) + by (simp cong: R.finsum_cong add: deg_aboveD R Pi_def) finally have "(\i \ {.. deg R p + deg R q}. ?s i) = coeff P p (deg R p) \ coeff P q (deg R q)" . with nz show "(\i \ {.. deg R p + deg R q}. ?s i) ~= \" @@ -983,8 +981,7 @@ have "... = coeff P (\\<^bsub>P\<^esub> i \ {.. {k}. ?s i) k" by (simp only: ivl_disj_un_singleton) also have "... = coeff P p k" - by (simp cong: R.finsum_cong - add: ivl_disj_int_singleton coeff_finsum deg_aboveD R RR Pi_def) + by (simp cong: R.finsum_cong add: coeff_finsum deg_aboveD R RR Pi_def) finally show ?thesis . next case False @@ -992,8 +989,7 @@ coeff P (\\<^bsub>P\<^esub> i \ {.. {deg R p}. ?s i) k" by (simp only: ivl_disj_un_singleton) also from False have "... = coeff P p k" - by (simp cong: R.finsum_cong - add: ivl_disj_int_singleton coeff_finsum deg_aboveD R Pi_def) + by (simp cong: R.finsum_cong add: coeff_finsum deg_aboveD R Pi_def) finally show ?thesis . qed qed (simp_all add: R Pi_def) diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Algebra/poly/UnivPoly2.thy --- a/src/HOL/Algebra/poly/UnivPoly2.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Algebra/poly/UnivPoly2.thy Mon Aug 31 14:09:42 2009 +0200 @@ -674,8 +674,7 @@ also have "... = setsum ?s ({deg p} Un {deg p <.. deg p + deg q})" by (simp only: ivl_disj_un_singleton) also have "... = coeff p (deg p) * coeff q (deg q)" - by (simp add: setsum_Un_disjoint ivl_disj_int_singleton - setsum_0 deg_aboveD) + by (simp add: setsum_Un_disjoint setsum_0 deg_aboveD) finally have "setsum ?s {.. deg p + deg q} = coeff p (deg p) * coeff q (deg q)" . with nz show "setsum ?s {.. deg p + deg q} ~= 0" @@ -719,8 +718,7 @@ have "... = coeff (setsum ?s ({.. a b a' b'. x = (a,b) \ y = (a',b')" by auto then obtain a b a' b' where xy[simp]: "x = (a,b)" "y=(a',b')" by blast assume H: ?lhs - {assume "a = 0 \ b = 0 \ a' = 0 \ b' = 0" hence ?rhs - using na nb H - apply (simp add: INum_def split_def isnormNum_def) - apply (cases "a = 0", simp_all) - apply (cases "b = 0", simp_all) - apply (cases "a' = 0", simp_all) - apply (cases "a' = 0", simp_all add: of_int_eq_0_iff) - done} + {assume "a = 0 \ b = 0 \ a' = 0 \ b' = 0" + hence ?rhs using na nb H + by (simp add: INum_def split_def isnormNum_def split: split_if_asm)} moreover { assume az: "a \ 0" and bz: "b \ 0" and a'z: "a'\0" and b'z: "b'\0" from az bz a'z b'z na nb have pos: "b > 0" "b' > 0" by (simp_all add: isnormNum_def) @@ -517,10 +512,7 @@ have n0: "isnormNum 0\<^sub>N" by simp show ?thesis using nx ny apply (simp only: isnormNum_unique[where ?'a = 'a, OF Nmul_normN[OF nx ny] n0, symmetric] Nmul[where ?'a = 'a]) - apply (simp add: INum_def split_def isnormNum_def fst_conv snd_conv) - apply (cases "a=0",simp_all) - apply (cases "a'=0",simp_all) - done + by (simp add: INum_def split_def isnormNum_def fst_conv snd_conv split: split_if_asm) } qed lemma Nneg_Nneg[simp]: "~\<^sub>N (~\<^sub>N c) = c" diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Continuity.thy --- a/src/HOL/Library/Continuity.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Continuity.thy Mon Aug 31 14:09:42 2009 +0200 @@ -156,7 +156,7 @@ apply (rule up_chainI) apply simp apply (drule Un_absorb1) -apply (auto simp add: nat_not_singleton) +apply (auto split:split_if_asm) done @@ -184,8 +184,7 @@ apply (rule down_chainI) apply simp apply (drule Int_absorb1) -apply auto -apply (auto simp add: nat_not_singleton) +apply (auto split:split_if_asm) done diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Convex_Euclidean_Space.thy --- a/src/HOL/Library/Convex_Euclidean_Space.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Convex_Euclidean_Space.thy Mon Aug 31 14:09:42 2009 +0200 @@ -3355,9 +3355,8 @@ qed(auto intro!:path_connected_singleton) next case False hence *:"{x::real^'n. norm(x - a) = r} = (\x. a + r *\<^sub>R x) ` {x. norm x = 1}" unfolding not_le apply -apply(rule set_ext,rule) unfolding image_iff apply(rule_tac x="(1/r) *\<^sub>R (x - a)" in bexI) unfolding mem_Collect_eq norm_scaleR by (auto simp add: scaleR_right_diff_distrib) - have ***:"\xa. (if xa = 0 then 0 else 1) \ 1 \ xa = 0" apply(rule ccontr) by auto have **:"{x::real^'n. norm x = 1} = (\x. (1/norm x) *\<^sub>R x) ` (UNIV - {0})" apply(rule set_ext,rule) - unfolding image_iff apply(rule_tac x=x in bexI) unfolding mem_Collect_eq by(auto intro!: ***) + unfolding image_iff apply(rule_tac x=x in bexI) unfolding mem_Collect_eq by(auto split:split_if_asm) have "continuous_on (UNIV - {0}) (\x::real^'n. 1 / norm x)" unfolding o_def continuous_on_eq_continuous_within apply(rule, rule continuous_at_within_inv[unfolded o_def inverse_eq_divide]) apply(rule continuous_at_within) apply(rule continuous_at_norm[unfolded o_def]) by auto diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Euclidean_Space.thy --- a/src/HOL/Library/Euclidean_Space.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Euclidean_Space.thy Mon Aug 31 14:09:42 2009 +0200 @@ -1055,28 +1055,6 @@ lemma norm_triangle_lt: "norm(x::real ^'n::finite) + norm(y) < e ==> norm(x + y) < e" by (metis basic_trans_rules(21) norm_triangle_ineq) -lemma setsum_delta: - assumes fS: "finite S" - shows "setsum (\k. if k=a then b k else 0) S = (if a \ S then b a else 0)" -proof- - let ?f = "(\k. if k=a then b k else 0)" - {assume a: "a \ S" - hence "\ k\ S. ?f k = 0" by simp - hence ?thesis using a by simp} - moreover - {assume a: "a \ S" - let ?A = "S - {a}" - let ?B = "{a}" - have eq: "S = ?A \ ?B" using a by blast - have dj: "?A \ ?B = {}" by simp - from fS have fAB: "finite ?A" "finite ?B" by auto - have "setsum ?f S = setsum ?f ?A + setsum ?f ?B" - using setsum_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] - by simp - then have ?thesis using a by simp} - ultimately show ?thesis by blast -qed - lemma component_le_norm: "\x$i\ <= norm (x::real ^ 'n::finite)" apply (simp add: norm_vector_def) apply (rule member_le_setL2, simp_all) @@ -2079,13 +2057,6 @@ lemma matrix_add_ldistrib: "(A ** (B + C)) = (A \ B) + (A \ C)" by (vector matrix_matrix_mult_def setsum_addf[symmetric] ring_simps) -lemma setsum_delta': - assumes fS: "finite S" shows - "setsum (\k. if a = k then b k else 0) S = - (if a\ S then b a else 0)" - using setsum_delta[OF fS, of a b, symmetric] - by (auto intro: setsum_cong) - lemma matrix_mul_lid: fixes A :: "'a::semiring_1 ^ 'm ^ 'n::finite" shows "mat 1 ** A = A" diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Formal_Power_Series.thy --- a/src/HOL/Library/Formal_Power_Series.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Formal_Power_Series.thy Mon Aug 31 14:09:42 2009 +0200 @@ -633,8 +633,7 @@ by (auto simp add: inverse_eq_divide power_divide) from k have kn: "k > n" - apply (simp add: leastP_def setge_def fps_sum_rep_nth) - by (cases "k \ n", auto) + by (simp add: leastP_def setge_def fps_sum_rep_nth split:split_if_asm) then have "dist (?s n) a < (1/2)^n" unfolding dth by (auto intro: power_strict_decreasing) also have "\ <= (1/2)^n0" using nn0 @@ -1244,10 +1243,9 @@ {assume n0: "n \ 0" then have u: "{0} \ ({1} \ {2..n}) = {0..n}" "{1}\{2..n} = {1..n}" "{0..n - 1}\{n} = {0..n}" - apply (simp_all add: expand_set_eq) by presburger+ + by (auto simp: expand_set_eq) have d: "{0} \ ({1} \ {2..n}) = {}" "{1} \ {2..n} = {}" - "{0..n - 1}\{n} ={}" using n0 - by (simp_all add: expand_set_eq, presburger+) + "{0..n - 1}\{n} ={}" using n0 by simp_all have f: "finite {0}" "finite {1}" "finite {2 .. n}" "finite {0 .. n - 1}" "finite {n}" by simp_all have "((1 - ?X) * ?sa) $ n = setsum (\i. (1 - ?X)$ i * ?sa $ (n - i)) {0 .. n}" diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Fundamental_Theorem_Algebra.thy --- a/src/HOL/Library/Fundamental_Theorem_Algebra.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Fundamental_Theorem_Algebra.thy Mon Aug 31 14:09:42 2009 +0200 @@ -577,11 +577,12 @@ next case (pCons c cs) {assume c0: "c = 0" - from pCons.hyps pCons.prems c0 have ?case apply auto + from pCons.hyps pCons.prems c0 have ?case + apply (auto) apply (rule_tac x="k+1" in exI) apply (rule_tac x="a" in exI, clarsimp) apply (rule_tac x="q" in exI) - by (auto simp add: power_Suc)} + by (auto)} moreover {assume c0: "c\0" hence ?case apply- diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Permutations.thy --- a/src/HOL/Library/Permutations.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Permutations.thy Mon Aug 31 14:09:42 2009 +0200 @@ -843,9 +843,7 @@ unfolding permutes_def by metis+ from eq have "(Fun.swap a b id o p) a = (Fun.swap a c id o q) a" by simp hence bc: "b = c" - apply (simp add: permutes_def pa qa o_def fun_upd_def swap_def id_def cong del: if_weak_cong) - apply (cases "a = b", auto) - by (cases "b = c", auto) + by (simp add: permutes_def pa qa o_def fun_upd_def swap_def id_def cong del: if_weak_cong split: split_if_asm) from eq[unfolded bc] have "(\p. Fun.swap a c id o p) (Fun.swap a c id o p) = (\p. Fun.swap a c id o p) (Fun.swap a c id o q)" by simp hence "p = q" unfolding o_assoc swap_id_idempotent by (simp add: o_def) diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Univ_Poly.thy --- a/src/HOL/Library/Univ_Poly.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Univ_Poly.thy Mon Aug 31 14:09:42 2009 +0200 @@ -820,37 +820,24 @@ done qed -lemma (in semiring_0) pnormalize_sing: "(pnormalize [x] = [x]) \ x \ 0" by simp +lemma (in semiring_0) pnormalize_sing: "(pnormalize [x] = [x]) \ x \ 0" +by simp lemma (in semiring_0) pnormalize_pair: "y \ 0 \ (pnormalize [x, y] = [x, y])" by simp lemma (in semiring_0) pnormal_cons: "pnormal p \ pnormal (c#p)" unfolding pnormal_def by simp lemma (in semiring_0) pnormal_tail: "p\[] \ pnormal (c#p) \ pnormal p" - unfolding pnormal_def - apply (cases "pnormalize p = []", auto) - by (cases "c = 0", auto) + unfolding pnormal_def by(auto split: split_if_asm) lemma (in semiring_0) pnormal_last_nonzero: "pnormal p ==> last p \ 0" -proof(induct p) - case Nil thus ?case by (simp add: pnormal_def) -next - case (Cons a as) thus ?case - apply (simp add: pnormal_def) - apply (cases "pnormalize as = []", simp_all) - apply (cases "as = []", simp_all) - apply (cases "a=0", simp_all) - apply (cases "a=0", simp_all) - done -qed +by(induct p) (simp_all add: pnormal_def split: split_if_asm) lemma (in semiring_0) pnormal_length: "pnormal p \ 0 < length p" unfolding pnormal_def length_greater_0_conv by blast lemma (in semiring_0) pnormal_last_length: "\0 < length p ; last p \ 0\ \ pnormal p" - apply (induct p, auto) - apply (case_tac "p = []", auto) - apply (simp add: pnormal_def) - by (rule pnormal_cons, auto) +by (induct p) (auto simp: pnormal_def split: split_if_asm) + lemma (in semiring_0) pnormal_id: "pnormal p \ (0 < length p \ last p \ 0)" using pnormal_last_length pnormal_length pnormal_last_nonzero by blast @@ -918,9 +905,7 @@ qed lemma (in semiring_0) pnormalize_eq: "last p \ 0 \ pnormalize p = p" - apply (induct p, auto) - apply (case_tac p, auto)+ - done +by (induct p) (auto split: split_if_asm) lemma (in semiring_0) last_pnormalize: "pnormalize p \ [] \ last (pnormalize p) \ 0" by (induct p, auto) diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Library/Word.thy --- a/src/HOL/Library/Word.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Library/Word.thy Mon Aug 31 14:09:42 2009 +0200 @@ -1008,12 +1008,7 @@ fix xs assume "length (norm_signed (\#xs)) = Suc (length xs)" thus "norm_signed (\#xs) = \#xs" - apply (simp add: norm_signed_Cons) - apply safe - apply simp_all - apply (rule norm_unsigned_equal) - apply assumption - done + by (simp add: norm_signed_Cons norm_unsigned_equal split: split_if_asm) next fix xs assume "length (norm_signed (\#xs)) = Suc (length xs)" diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Nat.thy --- a/src/HOL/Nat.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Nat.thy Mon Aug 31 14:09:42 2009 +0200 @@ -1588,9 +1588,6 @@ lemma zero_induct: "P k ==> (!!n. P (Suc n) ==> P n) ==> P 0" using inc_induct[of 0 k P] by blast -lemma nat_not_singleton: "(\x. x = (0::nat)) = False" - by auto - (*The others are i - j - k = i - (j + k), k \ j ==> j - k + i = j + i - k, diff -r 375db037f4d2 -r 341c83339aeb src/HOL/Set.thy --- a/src/HOL/Set.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/Set.thy Mon Aug 31 14:09:42 2009 +0200 @@ -1268,10 +1268,26 @@ "(insert a B) Int C = (if a \ C then insert a (B \ C) else B \ C)" by auto +lemma Int_insert_left_if0[simp]: + "a \ C \ (insert a B) Int C = B \ C" + by auto + +lemma Int_insert_left_if1[simp]: + "a \ C \ (insert a B) Int C = insert a (B Int C)" + by auto + lemma Int_insert_right: "A \ (insert a B) = (if a \ A then insert a (A \ B) else A \ B)" by auto +lemma Int_insert_right_if0[simp]: + "a \ A \ A Int (insert a B) = A Int B" + by auto + +lemma Int_insert_right_if1[simp]: + "a \ A \ A Int (insert a B) = insert a (A Int B)" + by auto + lemma Un_Int_distrib: "A \ (B \ C) = (A \ B) \ (A \ C)" by blast diff -r 375db037f4d2 -r 341c83339aeb src/HOL/SetInterval.thy --- a/src/HOL/SetInterval.thy Sat Aug 29 14:31:39 2009 +0200 +++ b/src/HOL/SetInterval.thy Mon Aug 31 14:09:42 2009 +0200 @@ -251,6 +251,38 @@ apply (simp add: less_imp_le) done +subsubsection {* Intersection *} + +context linorder +begin + +lemma Int_atLeastAtMost[simp]: "{a..b} Int {c..d} = {max a c .. min b d}" +by auto + +lemma Int_atLeastAtMostR1[simp]: "{..b} Int {c..d} = {c .. min b d}" +by auto + +lemma Int_atLeastAtMostR2[simp]: "{a..} Int {c..d} = {max a c .. d}" +by auto + +lemma Int_atLeastAtMostL1[simp]: "{a..b} Int {..d} = {a .. min b d}" +by auto + +lemma Int_atLeastAtMostL2[simp]: "{a..b} Int {c..} = {max a c .. b}" +by auto + +lemma Int_atLeastLessThan[simp]: "{a.. F \ (atMost n) LeadsTo common" apply (rule LeadsTo_weaken_R) apply (rule_tac f = id and l = n in GreaterThan_bounded_induct) -apply (simp_all (no_asm_simp)) +apply (simp_all (no_asm_simp) del: Int_insert_right_if1) apply (rule_tac [2] subset_refl) apply (blast dest: PSP_Stable2 intro: common_stable LeadsTo_weaken_R) done