equal
deleted
inserted
replaced
1782 using less apply arith |
1782 using less apply arith |
1783 apply(rule base) |
1783 apply(rule base) |
1784 apply (rule step, simp+) |
1784 apply (rule step, simp+) |
1785 done |
1785 done |
1786 |
1786 |
|
1787 theorem int_bidirectional_induct [case_names base step1 step2]: |
|
1788 fixes k :: int |
|
1789 assumes base: "P k" |
|
1790 and step1: "\<And>i. k \<le> i \<Longrightarrow> P i \<Longrightarrow> P (i + 1)" |
|
1791 and step2: "\<And>i. k \<ge> i \<Longrightarrow> P i \<Longrightarrow> P (i - 1)" |
|
1792 shows "P i" |
|
1793 proof - |
|
1794 have "i \<le> k \<or> i \<ge> k" by arith |
|
1795 then show ?thesis proof |
|
1796 assume "i \<ge> k" then show ?thesis using base |
|
1797 by (rule int_ge_induct) (fact step1) |
|
1798 next |
|
1799 assume "i \<le> k" then show ?thesis using base |
|
1800 by (rule int_le_induct) (fact step2) |
|
1801 qed |
|
1802 qed |
|
1803 |
1787 subsection{*Intermediate value theorems*} |
1804 subsection{*Intermediate value theorems*} |
1788 |
1805 |
1789 lemma int_val_lemma: |
1806 lemma int_val_lemma: |
1790 "(\<forall>i<n::nat. abs(f(i+1) - f i) \<le> 1) --> |
1807 "(\<forall>i<n::nat. abs(f(i+1) - f i) \<le> 1) --> |
1791 f 0 \<le> k --> k \<le> f n --> (\<exists>i \<le> n. f i = (k::int))" |
1808 f 0 \<le> k --> k \<le> f n --> (\<exists>i \<le> n. f i = (k::int))" |