1790 \begin{isamarkuptext}% |
1790 \begin{isamarkuptext}% |
1791 \noindent We can define a function which swaps the left and right subtrees recursively, using the |
1791 \noindent We can define a function which swaps the left and right subtrees recursively, using the |
1792 list functions \isa{rev} and \isa{map}:% |
1792 list functions \isa{rev} and \isa{map}:% |
1793 \end{isamarkuptext}% |
1793 \end{isamarkuptext}% |
1794 \isamarkuptrue% |
1794 \isamarkuptrue% |
1795 \isacommand{function}\isamarkupfalse% |
1795 \isacommand{lemma}\isamarkupfalse% |
|
1796 \ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}x\ {\isasymin}\ set\ l\ {\isasymLongrightarrow}\ f\ x\ {\isacharless}\ Suc\ {\isacharparenleft}list{\isacharunderscore}size\ f\ l{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
1797 % |
|
1798 \isadelimproof |
|
1799 % |
|
1800 \endisadelimproof |
|
1801 % |
|
1802 \isatagproof |
|
1803 \isacommand{by}\isamarkupfalse% |
|
1804 \ {\isacharparenleft}induct\ l{\isacharparenright}\ auto% |
|
1805 \endisatagproof |
|
1806 {\isafoldproof}% |
|
1807 % |
|
1808 \isadelimproof |
|
1809 \isanewline |
|
1810 % |
|
1811 \endisadelimproof |
|
1812 \isanewline |
|
1813 \isanewline |
|
1814 \isacommand{fun}\isamarkupfalse% |
1796 \ mirror\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ tree\ {\isasymRightarrow}\ {\isacharprime}a\ tree{\isachardoublequoteclose}\isanewline |
1815 \ mirror\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ tree\ {\isasymRightarrow}\ {\isacharprime}a\ tree{\isachardoublequoteclose}\isanewline |
1797 \isakeyword{where}\isanewline |
1816 \isakeyword{where}\isanewline |
1798 \ \ {\isachardoublequoteopen}mirror\ {\isacharparenleft}Leaf\ n{\isacharparenright}\ {\isacharequal}\ Leaf\ n{\isachardoublequoteclose}\isanewline |
1817 \ \ {\isachardoublequoteopen}mirror\ {\isacharparenleft}Leaf\ n{\isacharparenright}\ {\isacharequal}\ Leaf\ n{\isachardoublequoteclose}\isanewline |
1799 {\isacharbar}\ {\isachardoublequoteopen}mirror\ {\isacharparenleft}Branch\ l{\isacharparenright}\ {\isacharequal}\ Branch\ {\isacharparenleft}rev\ {\isacharparenleft}map\ mirror\ l{\isacharparenright}{\isacharparenright}{\isachardoublequoteclose}\isanewline |
1818 {\isacharbar}\ {\isachardoublequoteopen}mirror\ {\isacharparenleft}Branch\ l{\isacharparenright}\ {\isacharequal}\ Branch\ {\isacharparenleft}rev\ {\isacharparenleft}map\ mirror\ l{\isacharparenright}{\isacharparenright}{\isachardoublequoteclose}% |
1800 % |
1819 \begin{isamarkuptext}% |
1801 \isadelimproof |
1820 \emph{Note: The handling of size functions is currently changing |
1802 % |
1821 in the developers version of Isabelle. So this documentation is outdated.}% |
1803 \endisadelimproof |
|
1804 % |
|
1805 \isatagproof |
|
1806 \isacommand{by}\isamarkupfalse% |
|
1807 \ pat{\isacharunderscore}completeness\ auto% |
|
1808 \endisatagproof |
|
1809 {\isafoldproof}% |
|
1810 % |
|
1811 \isadelimproof |
|
1812 % |
|
1813 \endisadelimproof |
|
1814 % |
|
1815 \begin{isamarkuptext}% |
|
1816 We do the termination proof manually, to point out what happens |
|
1817 here:% |
|
1818 \end{isamarkuptext}% |
1822 \end{isamarkuptext}% |
1819 \isamarkuptrue% |
1823 \isamarkuptrue% |
1820 \isacommand{termination}\isamarkupfalse% |
1824 \isacommand{termination}\isamarkupfalse% |
1821 % |
1825 % |
1822 \isadelimproof |
1826 \isadelimproof |
1858 \ simp% |
1862 \ simp% |
1859 \begin{isamarkuptxt}% |
1863 \begin{isamarkuptxt}% |
1860 Simplification returns the following subgoal: |
1864 Simplification returns the following subgoal: |
1861 |
1865 |
1862 \begin{isabelle}% |
1866 \begin{isabelle}% |
1863 {\isadigit{1}}{\isachardot}\ x\ {\isasymin}\ set\ l\ {\isasymLongrightarrow}\ size\ x\ {\isacharless}\ Suc\ {\isacharparenleft}tree{\isacharunderscore}list{\isacharunderscore}size\ l{\isacharparenright}% |
1867 {\isadigit{1}}{\isachardot}\ x\ {\isasymin}\ set\ l\ {\isasymLongrightarrow}\ size\ x\ {\isacharless}\ Suc\ {\isacharparenleft}list{\isacharunderscore}size\ size\ l{\isacharparenright}% |
1864 \end{isabelle} |
1868 \end{isabelle} |
1865 |
1869 |
1866 We are lacking a property about the function \isa{tree{\isacharunderscore}list{\isacharunderscore}size}, which was generated automatically at the |
1870 We are lacking a property about the function \isa{tree{\isacharunderscore}list{\isacharunderscore}size}, which was generated automatically at the |
1867 definition of the \isa{tree} type. We should go back and prove |
1871 definition of the \isa{tree} type. We should go back and prove |
1868 it, by induction.% |
1872 it, by induction.% |
1869 \end{isamarkuptxt}% |
1873 \end{isamarkuptxt}% |
1870 \isamarkuptrue% |
1874 \isamarkuptrue% |
1871 \ \ \ \ % |
1875 \ \ \ \ % |
1872 \endisatagproof |
|
1873 {\isafoldproof}% |
|
1874 % |
|
1875 \isadelimproof |
|
1876 % |
|
1877 \endisadelimproof |
|
1878 \isanewline |
|
1879 \isacommand{lemma}\isamarkupfalse% |
|
1880 \ tree{\isacharunderscore}list{\isacharunderscore}size{\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ \isanewline |
|
1881 \ \ {\isachardoublequoteopen}x\ {\isasymin}\ set\ l\ {\isasymLongrightarrow}\ size\ x\ {\isacharless}\ Suc\ {\isacharparenleft}tree{\isacharunderscore}list{\isacharunderscore}size\ l{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
1882 % |
|
1883 \isadelimproof |
|
1884 % |
|
1885 \endisadelimproof |
|
1886 % |
|
1887 \isatagproof |
|
1888 \isacommand{by}\isamarkupfalse% |
|
1889 \ {\isacharparenleft}induct\ l{\isacharparenright}\ auto% |
|
1890 \endisatagproof |
1876 \endisatagproof |
1891 {\isafoldproof}% |
1877 {\isafoldproof}% |
1892 % |
1878 % |
1893 \isadelimproof |
1879 \isadelimproof |
1894 % |
1880 % |