126 \begin{tikzpicture}[x = 4.2cm, y = 1cm] |
126 \begin{tikzpicture}[x = 4.2cm, y = 1cm] |
127 \tikzstyle entity=[rounded corners, draw, thick, color = black, fill = white]; |
127 \tikzstyle entity=[rounded corners, draw, thick, color = black, fill = white]; |
128 \tikzstyle process=[ellipse, draw, thick, color = green, fill = white]; |
128 \tikzstyle process=[ellipse, draw, thick, color = green, fill = white]; |
129 \tikzstyle process_arrow=[->, semithick, color = green]; |
129 \tikzstyle process_arrow=[->, semithick, color = green]; |
130 \node (HOL) at (0, 4) [style=entity] {@{text "Isabelle/HOL"} theory}; |
130 \node (HOL) at (0, 4) [style=entity] {@{text "Isabelle/HOL"} theory}; |
131 \node (eqn) at (2, 2) [style=entity] {defining equations}; |
131 \node (eqn) at (2, 2) [style=entity] {code equations}; |
132 \node (iml) at (2, 0) [style=entity] {intermediate language}; |
132 \node (iml) at (2, 0) [style=entity] {intermediate language}; |
133 \node (seri) at (1, 0) [style=process] {serialisation}; |
133 \node (seri) at (1, 0) [style=process] {serialisation}; |
134 \node (SML) at (0, 3) [style=entity] {@{text SML}}; |
134 \node (SML) at (0, 3) [style=entity] {@{text SML}}; |
135 \node (OCaml) at (0, 2) [style=entity] {@{text OCaml}}; |
135 \node (OCaml) at (0, 2) [style=entity] {@{text OCaml}}; |
136 \node (further) at (0, 1) [style=entity] {@{text "\<dots>"}}; |
136 \node (further) at (0, 1) [style=entity] {@{text "\<dots>"}}; |
151 \end{figure} |
151 \end{figure} |
152 |
152 |
153 The code generator employs a notion of executability |
153 The code generator employs a notion of executability |
154 for three foundational executable ingredients known |
154 for three foundational executable ingredients known |
155 from functional programming: |
155 from functional programming: |
156 \emph{defining equations}, \emph{datatypes}, and |
156 \emph{code equations}, \emph{datatypes}, and |
157 \emph{type classes}. A defining equation as a first approximation |
157 \emph{type classes}. A code equation as a first approximation |
158 is a theorem of the form @{text "f t\<^isub>1 t\<^isub>2 \<dots> t\<^isub>n \<equiv> t"} |
158 is a theorem of the form @{text "f t\<^isub>1 t\<^isub>2 \<dots> t\<^isub>n \<equiv> t"} |
159 (an equation headed by a constant @{text f} with arguments |
159 (an equation headed by a constant @{text f} with arguments |
160 @{text "t\<^isub>1 t\<^isub>2 \<dots> t\<^isub>n"} and right hand side @{text t}). |
160 @{text "t\<^isub>1 t\<^isub>2 \<dots> t\<^isub>n"} and right hand side @{text t}). |
161 Code generation aims to turn defining equations |
161 Code generation aims to turn code equations |
162 into a functional program. This is achieved by three major |
162 into a functional program. This is achieved by three major |
163 components which operate sequentially, i.e. the result of one is |
163 components which operate sequentially, i.e. the result of one is |
164 the input |
164 the input |
165 of the next in the chain, see diagram \ref{fig:arch}: |
165 of the next in the chain, see diagram \ref{fig:arch}: |
166 |
166 |
167 \begin{itemize} |
167 \begin{itemize} |
168 |
168 |
169 \item Out of the vast collection of theorems proven in a |
169 \item Out of the vast collection of theorems proven in a |
170 \qn{theory}, a reasonable subset modelling |
170 \qn{theory}, a reasonable subset modelling |
171 defining equations is \qn{selected}. |
171 code equations is \qn{selected}. |
172 |
172 |
173 \item On those selected theorems, certain |
173 \item On those selected theorems, certain |
174 transformations are carried out |
174 transformations are carried out |
175 (\qn{preprocessing}). Their purpose is to turn theorems |
175 (\qn{preprocessing}). Their purpose is to turn theorems |
176 representing non- or badly executable |
176 representing non- or badly executable |
177 specifications into equivalent but executable counterparts. |
177 specifications into equivalent but executable counterparts. |
178 The result is a structured collection of \qn{code theorems}. |
178 The result is a structured collection of \qn{code theorems}. |
179 |
179 |
180 \item Before the selected defining equations are continued with, |
180 \item Before the selected code equations are continued with, |
181 they can be \qn{preprocessed}, i.e. subjected to theorem |
181 they can be \qn{preprocessed}, i.e. subjected to theorem |
182 transformations. This \qn{preprocessor} is an interface which |
182 transformations. This \qn{preprocessor} is an interface which |
183 allows to apply |
183 allows to apply |
184 the full expressiveness of ML-based theorem transformations |
184 the full expressiveness of ML-based theorem transformations |
185 to code generation; motivating examples are shown below, see |
185 to code generation; motivating examples are shown below, see |
186 \secref{sec:preproc}. |
186 \secref{sec:preproc}. |
187 The result of the preprocessing step is a structured collection |
187 The result of the preprocessing step is a structured collection |
188 of defining equations. |
188 of code equations. |
189 |
189 |
190 \item These defining equations are \qn{translated} to a program |
190 \item These code equations are \qn{translated} to a program |
191 in an abstract intermediate language. Think of it as a kind |
191 in an abstract intermediate language. Think of it as a kind |
192 of \qt{Mini-Haskell} with four \qn{statements}: @{text data} |
192 of \qt{Mini-Haskell} with four \qn{statements}: @{text data} |
193 (for datatypes), @{text fun} (stemming from defining equations), |
193 (for datatypes), @{text fun} (stemming from code equations), |
194 also @{text class} and @{text inst} (for type classes). |
194 also @{text class} and @{text inst} (for type classes). |
195 |
195 |
196 \item Finally, the abstract program is \qn{serialised} into concrete |
196 \item Finally, the abstract program is \qn{serialised} into concrete |
197 source code of a target language. |
197 source code of a target language. |
198 |
198 |