1 \subsection {Mathematical background}
3 As a mathematical background for the semantics, we take the one presented in
6 {\Str} denotes the type of strings and its elements are the finite sequences
7 of Unicode \cite{Unicode} characters.
8 Grammatical productions, represented as strings in angle brackets, denote the
9 subtype of {\Str} containing the produced sequences of characters.
11 {\Num} denotes the type of numbers and is the subtype of {\Str} defined by the
12 regular expression: \TT{'0 - 9' [ '0 - 9' ]*}.
13 In this type, numbers are represented by their decimal expansion.
15 $ \Setof\ Y $ denotes the type of finite sets ({\ie} unordered finite
16 sequences without repetitions) over $ Y $.
17 $ \Listof\ Y $ denotes the type of lists ({\ie} ordered finite sequences)
19 We will use the notation $ [y_1, \cdots, y_m] $ for the list whose elements
20 are $ y_1, \cdots, y_m $.
22 {\Boole}, the type of Boolean values, is defined as
23 $ \{\ES, \{("", \ES)\}\} \oft \Setof\ \Setof\ (\Str \times \Setof\ Y) $
24 where the first element stands for \emph{false} (denoted by {\F}) and the
25 second element stands for \emph{true} (denoted by {\T}).
27 $ Y \times Z $ denotes the product of the types $ Y $ and $ Z $ whose elements
28 are the ordered pairs $ (y, z) $ such that $ y \oft Y $ and $ z \oft Z $.
29 The notation is also extended to a ternary product.
31 $ Y \to Z $ denotes the type of functions from $ Y $ to $ Z $ and $ f\ y $
32 denotes the application of $ f \oft Y \to Z $ to $ y \oft Y $.
33 Relations over types, such as equality, are seen as functions to {\Boole}.
35 With the above constructors we can give a formal meaning to most of the
36 standard notation. For instance we will use the following:
41 $ {\ES} \oft (\Setof\ Y) $
44 $ {\lex} \oft ((\Setof\ Y) \to \Boole) \to \Boole $
47 $ {\lall} \oft ((\Setof\ Y) \to \Boole) \to \Boole $
50 $ {\in} \oft Y \to (\Setof\ Y) \to \Boole $ (infix)
53 $ {\sub} \oft (\Setof\ Y) \to (\Setof\ Y) \to \Boole $ (infix)
56 $ {\meet} \oft (\Setof\ Y) \to (\Setof\ Y) \to \Boole $ (infix)
59 $ {\sand} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $ (infix)
62 $ {\sor} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $ (infix)
65 $ {\sdor} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $
66 (the disjoint union, infix)
69 $ \le \oft \Num \to \Num \to \Boole $ (infix)
72 $ < \oft \Num \to \Num \to \Boole $ (infix)
75 $ \# \oft (\Setof\ Y) \to \Num $ (the size operator)
78 $ \app \oft (\Listof\ Y) \to (\Listof\ Y) \to (\Listof\ Y) $
79 (the concatenation, infix)
82 $ \lnot \oft \Boole \to \Boole $
87 Note that $ \lall $ and $ \lex $ are always decidable because the sets are
91 $ U \meet W $ means $ (\lex u \in U)\ u \in W $ and expresses the fact that
92 $ U \sand W $ is inhabited as a primitive notion, {\ie} without mentioning
93 intersection and equality as for $ U \sand W \neq \ES $, which is equivalent
94 but may be implemented less efficiently in real cases%
95 \footnote{As for the Boolean condition $ \a \lor \b $ which may have a more
96 efficient implementation than $ \lnot(\lnot \a \land \lnot \b) $.}.
98 $ U \meet W $ is a natural companion of $ U \sub W $ being its logical dual
99 (recall that $ U \sub W $ means $ (\lall u \in U)\ u \in W $)
100 and is already being used successfully in the context of a constructive
101 ({\ie} intuitionistic and predicative) approach to point-free topology
104 Sets of couples play a central role in our formalization and in particular we
110 $ \Fst \oft (Y \times Z) \to Y $ such that $ \Fst\ (y, z) = y $.
113 $ \Snd \oft (Y \times Z) \to Z $ such that $ \Snd\ (y, z) = z $.
116 $ \Fsts \oft \Setof\ (Y \times Z) \to \Setof\ Z $ such that
117 $ \Fsts\ U = \{\Fst\ u \st u \in U\} $.
120 With the same notation, if $ W $ contains just one couple whose first
121 component is $ y $, then $ \get{W}{y} $ is the second component of that couple.
122 In the other cases $ \get{W}{y} $ is not defined.
123 This operator has type $ (\Setof\ (Y \times Z)) \to Y \to Z $.
126 Moreover $ \set{W}{y}{z} $ is the set obtained from $ W $ removing every
127 couple whose first component is $ y $ and adding the couple $ (y, z) $.
128 The type of this operator is \\
129 $ (\Setof\ (Y \times Z)) \to Y \to Z \to (\Setof\ (Y \times Z)) $.
132 Also $ U + W $ is the union of two sets of couples in the following sense:
135 \begin{center} \begin{tabular}{rll}
137 $ U + \ES $ & rewrites to & $ U $ \\
138 $ U + (W \sdor \{(y, z)\}) $ & rewrites to & $ \set{U}{y}{z} + W $
140 \end{tabular} \end{center}
145 The last three operators are used to read, write and join association sets,
146 which are sets of couples such that the first components of two different
147 elements are always different.
148 These sets will be exploited to formalize the memories appearing in evaluation