1 \subsection {Mathematical background}
3 As background for the semantics, we revise 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 denote the subtype of {\Str} containing the produced
9 sequences of characters.
11 {\Num} denotes the type of numbers and is the subtype of {\Str} defined by
12 \GP{num}. In this type, numbers are represented by their decimal expansion.
14 $ \Setof\ Y $ denotes the type of finite sets ({\ie} unordered finite
15 sequences without repetitions) over $ Y $ and
16 $ \Listof\ Y $ denotes the type of lists ({\ie} ordered finite sequences)
18 We will use the notation $ [y_1, \cdots, y_m] $ for the list whose elements
19 are $ y_1, \cdots, y_m $ ($ \{y_1, \cdots, y_m\} $ will denote a set as
22 {\Boole}, the type of Boolean values, is defined as the set
23 $ \{\ES, \{("", \ES)\}\} $ of type $ \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}).%
26 \footnote{This definition allows to treat a Boolean value as an {\av} set.}
28 $ Y \times Z $ denotes the product of the types $ Y $ and $ Z $ whose elements
29 are the ordered pairs $ (y, z) $ such that $ y \oft Y $ and $ z \oft Z $.
30 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 $ \fa \lor \fb $ which may have a more
96 efficient implementation than $ \lnot(\lnot \fa \land \lnot \fb) $.}.
97 $ U \meet W $ is a natural companion of $ U \sub W $ being its logical dual
98 (recall that $ U \sub W $ means $ (\lall u \in U)\ u \in W $)
99 and is already being used successfully in the context of a constructive
100 ({\ie} intuitionistic and predicative) approach to point-free topology
103 Sets of couples play a central role in our presentation and we will use:
108 $ \Fst \oft (Y \times Z) \to Y $ such that $ \Fst\ (y, z) = y $.
111 $ \Snd \oft (Y \times Z) \to Z $ such that $ \Snd\ (y, z) = z $.
114 $ \Fsts \oft \Setof\ (Y \times Z) \to \Setof\ Z $ such that
115 $ \Fsts\ U = \{\Fst\ u \st u \in U\} $.
118 With the same notation, if $ W $ contains just one couple whose first
119 component is $ y $, then $ \get{W}{y} $ is the second component of that couple.
120 In the other cases $ \get{W}{y} $ is not defined.
121 This operator has type $ (\Setof\ (Y \times Z)) \to Y \to Z $.
124 Moreover $ \set{W}{y}{z} $ is the set obtained from $ W $ removing every
125 couple whose first component is $ y $ and adding the couple $ (y, z) $.
126 The type of this operator is
127 $ (\Setof\ (Y \times Z)) \to Y \to Z \to (\Setof\ (Y \times Z)) $.
130 Also $ U + W $ is the union of two sets of couples in the following sense:
133 \begin{center} \begin{tabular}{rll}
135 $ U + \ES $ & rewrites to & $ U $ \\
136 $ U + (W \sdor \{(y, z)\}) $ & rewrites to & $ \set{U}{y}{z} + W $
138 \end{tabular} \end{center}
143 The last three operators are used to read, write and join association sets,
144 which are sets of couples such that the first components of two different
145 elements are always different.
146 These sets will be exploited to formalize the memories appearing in evaluation