131 \begin{isamarkuptext}% |
131 \begin{isamarkuptext}% |
132 \noindent |
132 \noindent |
133 When Isabelle prints a syntax error message, it refers to the HOL syntax as |
133 When Isabelle prints a syntax error message, it refers to the HOL syntax as |
134 the \textbf{inner syntax} and the enclosing theory language as the \textbf{outer syntax}. |
134 the \textbf{inner syntax} and the enclosing theory language as the \textbf{outer syntax}. |
135 |
135 |
|
136 \section{Evaluation} |
|
137 \index{evaluation} |
|
138 |
|
139 Assuming you have processed the declarations and definitions of |
|
140 \texttt{ToyList} presented so far, you may want to test your |
|
141 functions by running them. For example, what is the value of |
|
142 \isa{rev\ {\isacharparenleft}True\ {\isacharhash}\ False\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}}? Command% |
|
143 \end{isamarkuptext}% |
|
144 \isamarkuptrue% |
|
145 \isacommand{value}\isamarkupfalse% |
|
146 \ {\isachardoublequoteopen}rev\ {\isacharparenleft}True\ {\isacharhash}\ False\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}{\isachardoublequoteclose}% |
|
147 \begin{isamarkuptext}% |
|
148 \noindent yields the correct result \isa{False\ {\isacharhash}\ True\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}}. |
|
149 But we can go beyond mere functional programming and evaluate terms with |
|
150 variables in them, executing functions symbolically:% |
|
151 \end{isamarkuptext}% |
|
152 \isamarkuptrue% |
|
153 \isacommand{normal{\isacharunderscore}form}\isamarkupfalse% |
|
154 \ {\isachardoublequoteopen}rev\ {\isacharparenleft}a\ {\isacharhash}\ b\ {\isacharhash}\ c\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}{\isachardoublequoteclose}% |
|
155 \begin{isamarkuptext}% |
|
156 \noindent yields \isa{c\ {\isacharhash}\ b\ {\isacharhash}\ a\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}}. |
|
157 Command \commdx{normal\protect\_form} works for arbitrary terms |
|
158 but can be slower than command \commdx{value}, |
|
159 which is restricted to variable-free terms and executable functions. |
|
160 To appreciate the subtleties of evaluating terms with variables, |
|
161 try this one:% |
|
162 \end{isamarkuptext}% |
|
163 \isamarkuptrue% |
|
164 \isacommand{normal{\isacharunderscore}form}\isamarkupfalse% |
|
165 \ {\isachardoublequoteopen}rev\ {\isacharparenleft}a\ {\isacharhash}\ b\ {\isacharhash}\ c\ {\isacharhash}\ xs{\isacharparenright}{\isachardoublequoteclose}% |
|
166 \begin{isamarkuptext}% |
|
167 \noindent Chances are that the result will at first puzzle you. |
136 |
168 |
137 \section{An Introductory Proof} |
169 \section{An Introductory Proof} |
138 \label{sec:intro-proof} |
170 \label{sec:intro-proof} |
139 |
171 |
140 Assuming you have processed the declarations and definitions of |
172 Having convinced ourselves (as well as one can by testing) that our |
141 \texttt{ToyList} presented so far, we are ready to prove a few simple |
173 definitions capture our intentions, we are ready to prove a few simple |
142 theorems. This will illustrate not just the basic proof commands but |
174 theorems. This will illustrate not just the basic proof commands but |
143 also the typical proof process. |
175 also the typical proof process. |
144 |
176 |
145 \subsubsection*{Main Goal.} |
177 \subsubsection*{Main Goal.} |
146 |
178 |