Theory itp_2010
section ‹\isaheader{Examples from ITP-2010 slides (adopted to ICF v2)}›
theory itp_2010
imports
Collections.Collections
Collections.Code_Target_ICF
begin
text ‹
Illustrates the various possibilities how to use the ICF in your own
algorithms by simple examples. The examples all use the data refinement
scheme, and either define a generic algorithm or fix the operations.
›
subsection "List to Set"
text ‹
In this simple example we do conversion from a list to a set.
We define an abstract algorithm.
This is then refined by a generic algorithm using a locale and by a generic
algorithm fixing its operations as parameters.
›
subsubsection "Straightforward version"
fun set_a where
"set_a [] s = s" |
"set_a (a#l) s = set_a l (insert a s)"
lemma set_a_correct: "set_a l s = set l ∪ s"
by (induct l arbitrary: s) auto
setup Locale_Code.open_block