author | nipkow |
Sun, 23 Oct 2011 14:15:24 +0200 | |
changeset 45256 | 62b025f434e9 |
parent 44177 | b4b5cbca2519 |
permissions | -rw-r--r-- |
43158 | 1 |
(* Author: Tobias Nipkow *) |
2 |
||
3 |
theory Util imports Main |
|
4 |
begin |
|
5 |
||
6 |
subsection "Show sets of variables as lists" |
|
7 |
||
44177
b4b5cbca2519
IMP/Util distinguishes between sets and functions again; imported only where used.
kleing
parents:
44174
diff
changeset
|
8 |
text {* Sets may be infinite and are not always displayed by element |
b4b5cbca2519
IMP/Util distinguishes between sets and functions again; imported only where used.
kleing
parents:
44174
diff
changeset
|
9 |
if computed as values. Lists do not have this problem. |
43158 | 10 |
|
44177
b4b5cbca2519
IMP/Util distinguishes between sets and functions again; imported only where used.
kleing
parents:
44174
diff
changeset
|
11 |
We define a function @{text show} that converts a set of |
43158 | 12 |
variable names into a list. To keep things simple, we rely on |
13 |
the convention that we only use single letter names. |
|
14 |
*} |
|
15 |
definition |
|
16 |
letters :: "string list" where |
|
17 |
"letters = map (\<lambda>c. [c]) chars" |
|
18 |
||
19 |
definition |
|
20 |
"show" :: "string set \<Rightarrow> string list" where |
|
44174
d1d79f0e1ea6
make more HOL theories work with separate set type
huffman
parents:
43158
diff
changeset
|
21 |
"show S = filter (\<lambda>x. x \<in> S) letters" |
43158 | 22 |
|
23 |
value "show {''x'', ''z''}" |
|
24 |
||
25 |
end |