796 apply (simp_all add: atLeastLessThanSuc) |
796 apply (simp_all add: atLeastLessThanSuc) |
797 done |
797 done |
798 |
798 |
799 subsubsection \<open>Intervals and numerals\<close> |
799 subsubsection \<open>Intervals and numerals\<close> |
800 |
800 |
801 lemma lessThan_nat_numeral: --\<open>Evaluation for specific numerals\<close> |
801 lemma lessThan_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> |
802 "lessThan (numeral k :: nat) = insert (pred_numeral k) (lessThan (pred_numeral k))" |
802 "lessThan (numeral k :: nat) = insert (pred_numeral k) (lessThan (pred_numeral k))" |
803 by (simp add: numeral_eq_Suc lessThan_Suc) |
803 by (simp add: numeral_eq_Suc lessThan_Suc) |
804 |
804 |
805 lemma atMost_nat_numeral: --\<open>Evaluation for specific numerals\<close> |
805 lemma atMost_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> |
806 "atMost (numeral k :: nat) = insert (numeral k) (atMost (pred_numeral k))" |
806 "atMost (numeral k :: nat) = insert (numeral k) (atMost (pred_numeral k))" |
807 by (simp add: numeral_eq_Suc atMost_Suc) |
807 by (simp add: numeral_eq_Suc atMost_Suc) |
808 |
808 |
809 lemma atLeastLessThan_nat_numeral: --\<open>Evaluation for specific numerals\<close> |
809 lemma atLeastLessThan_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> |
810 "atLeastLessThan m (numeral k :: nat) = |
810 "atLeastLessThan m (numeral k :: nat) = |
811 (if m \<le> (pred_numeral k) then insert (pred_numeral k) (atLeastLessThan m (pred_numeral k)) |
811 (if m \<le> (pred_numeral k) then insert (pred_numeral k) (atLeastLessThan m (pred_numeral k)) |
812 else {})" |
812 else {})" |
813 by (simp add: numeral_eq_Suc atLeastLessThanSuc) |
813 by (simp add: numeral_eq_Suc atLeastLessThanSuc) |
814 |
814 |
1466 \end{center} |
1466 \end{center} |
1467 The left column shows the term before introduction of the new syntax, |
1467 The left column shows the term before introduction of the new syntax, |
1468 the middle column shows the new (default) syntax, and the right column |
1468 the middle column shows the new (default) syntax, and the right column |
1469 shows a special syntax. The latter is only meaningful for latex output |
1469 shows a special syntax. The latter is only meaningful for latex output |
1470 and has to be activated explicitly by setting the print mode to |
1470 and has to be activated explicitly by setting the print mode to |
1471 @{text latex_sum} (e.g.\ via @{text "mode = latex_sum"} in |
1471 \<open>latex_sum\<close> (e.g.\ via \<open>mode = latex_sum\<close> in |
1472 antiquotations). It is not the default \LaTeX\ output because it only |
1472 antiquotations). It is not the default \LaTeX\ output because it only |
1473 works well with italic-style formulae, not tt-style. |
1473 works well with italic-style formulae, not tt-style. |
1474 |
1474 |
1475 Note that for uniformity on @{typ nat} it is better to use |
1475 Note that for uniformity on @{typ nat} it is better to use |
1476 @{term"\<Sum>x::nat=0..<n. e"} rather than @{text"\<Sum>x<n. e"}: @{text setsum} may |
1476 @{term"\<Sum>x::nat=0..<n. e"} rather than \<open>\<Sum>x<n. e\<close>: \<open>setsum\<close> may |
1477 not provide all lemmas available for @{term"{m..<n}"} also in the |
1477 not provide all lemmas available for @{term"{m..<n}"} also in the |
1478 special form for @{term"{..<n}"}.\<close> |
1478 special form for @{term"{..<n}"}.\<close> |
1479 |
1479 |
1480 text\<open>This congruence rule should be used for sums over intervals as |
1480 text\<open>This congruence rule should be used for sums over intervals as |
1481 the standard theorem @{text[source]setsum.cong} does not work well |
1481 the standard theorem @{text[source]setsum.cong} does not work well |
1695 also have "... = (x - y) * (\<Sum>p<Suc (Suc n). x ^ p * y ^ (Suc n - p))" |
1695 also have "... = (x - y) * (\<Sum>p<Suc (Suc n). x ^ p * y ^ (Suc n - p))" |
1696 by (simp add: power_Suc field_simps Suc_diff_le setsum_left_distrib setsum_right_distrib) |
1696 by (simp add: power_Suc field_simps Suc_diff_le setsum_left_distrib setsum_right_distrib) |
1697 finally show ?case . |
1697 finally show ?case . |
1698 qed simp |
1698 qed simp |
1699 |
1699 |
1700 corollary power_diff_sumr2: --\<open>@{text COMPLEX_POLYFUN} in HOL Light\<close> |
1700 corollary power_diff_sumr2: \<comment>\<open>\<open>COMPLEX_POLYFUN\<close> in HOL Light\<close> |
1701 fixes x :: "'a::{comm_ring,monoid_mult}" |
1701 fixes x :: "'a::{comm_ring,monoid_mult}" |
1702 shows "x^n - y^n = (x - y) * (\<Sum>i<n. y^(n - Suc i) * x^i)" |
1702 shows "x^n - y^n = (x - y) * (\<Sum>i<n. y^(n - Suc i) * x^i)" |
1703 using diff_power_eq_setsum[of x "n - 1" y] |
1703 using diff_power_eq_setsum[of x "n - 1" y] |
1704 by (cases "n = 0") (simp_all add: field_simps) |
1704 by (cases "n = 0") (simp_all add: field_simps) |
1705 |
1705 |