src/HOL/IMP/Util.thy
author kleing
Mon, 06 Jun 2011 16:29:38 +0200
changeset 43999 686fa0a0696e
child 45045 d1d79f0e1ea6
permissions -rw-r--r--
imported rest of new IMP
kleing@43999
     1
(* Author: Tobias Nipkow *)
kleing@43999
     2
kleing@43999
     3
theory Util imports Main
kleing@43999
     4
begin
kleing@43999
     5
kleing@43999
     6
subsection "Show sets of variables as lists"
kleing@43999
     7
kleing@43999
     8
text {* Sets are functions and are not displayed by element if
kleing@43999
     9
computed as values: *}
kleing@43999
    10
value "{''x'', ''y''}"
kleing@43999
    11
kleing@43999
    12
text {* Lists do not have this problem *}
kleing@43999
    13
value "[''x'', ''y'']"
kleing@43999
    14
kleing@43999
    15
text {* We define a function @{text show} that converts a set of
kleing@43999
    16
  variable names into a list. To keep things simple, we rely on
kleing@43999
    17
  the convention that we only use single letter names.
kleing@43999
    18
*}
kleing@43999
    19
definition 
kleing@43999
    20
  letters :: "string list" where
kleing@43999
    21
  "letters = map (\<lambda>c. [c]) chars"
kleing@43999
    22
kleing@43999
    23
definition 
kleing@43999
    24
  "show" :: "string set \<Rightarrow> string list" where
kleing@43999
    25
  "show S = filter S letters" 
kleing@43999
    26
kleing@43999
    27
value "show {''x'', ''z''}"
kleing@43999
    28
kleing@43999
    29
end