diff -r cf0c60e821bb -r d4f6e64ee7cc src/HOL/SetInterval.thy --- a/src/HOL/SetInterval.thy Sat Jul 19 11:05:18 2008 +0200 +++ b/src/HOL/SetInterval.thy Sat Jul 19 19:27:13 2008 +0200 @@ -558,6 +558,54 @@ lemma card_greaterThanLessThan_int [simp]: "card {l<.. k < (i::nat)}" +proof - + have "{k. P k \ k < i} \ {.. M" +shows "card {k \ M. k < Suc i} \ 0" +proof - + from zero_in_M have "{k \ M. k < Suc i} \ {}" by auto + with finite_M_bounded_by_nat show ?thesis by (auto simp add: card_eq_0_iff) +qed + +lemma card_less_Suc2: "0 \ M \ card {k. Suc k \ M \ k < i} = card {k \ M. k < Suc i}" +apply (rule card_bij_eq [of "Suc" _ _ "\x. x - 1"]) +apply simp +apply fastsimp +apply auto +apply (rule inj_on_diff_nat) +apply auto +apply (case_tac x) +apply auto +apply (case_tac xa) +apply auto +apply (case_tac xa) +apply auto +apply (auto simp add: finite_M_bounded_by_nat) +done + +lemma card_less_Suc: + assumes zero_in_M: "0 \ M" + shows "Suc (card {k. Suc k \ M \ k < i}) = card {k \ M. k < Suc i}" +proof - + from assms have a: "0 \ {k \ M. k < Suc i}" by simp + hence c: "{k \ M. k < Suc i} = insert 0 ({k \ M. k < Suc i} - {0})" + by (auto simp only: insert_Diff) + have b: "{k \ M. k < Suc i} - {0} = {k \ M - {0}. k < Suc i}" by auto + from finite_M_bounded_by_nat[of "\x. x \ M" "Suc i"] have "Suc (card {k. Suc k \ M \ k < i}) = card (insert 0 ({k \ M. k < Suc i} - {0}))" + apply (subst card_insert) + apply simp_all + apply (subst b) + apply (subst card_less_Suc2[symmetric]) + apply simp_all + done + with c show ?thesis by simp +qed + subsection {*Lemmas useful with the summation operator setsum*}