1 \documentclass[a4paper]{article}
8 \newcommand{\MATITA}{\ding{46}\textsf{\textbf{Matita}}}
10 \title{Continuationals semantics for \MATITA}
11 \author{Claudio Sacerdoti Coen \quad Enrico Tassi \quad Stefano Zacchiroli \\
12 \small Department of Computer Science, University of Bologna \\
13 \small Mura Anteo Zamboni, 7 -- 40127 Bologna, ITALY \\
14 \small \{\texttt{sacerdot}, \texttt{tassi}, \texttt{zacchiro}\}\texttt{@cs.unibo.it}}
16 \newcommand{\MATHIT}[1]{\ensuremath{\mathit{#1}}}
17 \newcommand{\MATHTT}[1]{\ensuremath{\mathtt{#1}}}
19 \newcommand{\DOT}{\ensuremath{\mbox{\textbf{.}}}}
20 \newcommand{\SEMICOLON}{\ensuremath{\mbox{\textbf{;}}}}
21 \newcommand{\BRANCH}{\ensuremath{\mbox{\textbf{[}}}}
22 \newcommand{\SHIFT}{\ensuremath{\mbox{\textbf{\textbar}}}}
23 \newcommand{\POS}[1]{\ensuremath{#1\mbox{\textbf{:}}}}
24 \newcommand{\MERGE}{\ensuremath{\mbox{\textbf{]}}}}
25 \newcommand{\FOCUS}[1]{\ensuremath{\mathtt{focus}~#1}}
26 \newcommand{\UNFOCUS}{\ensuremath{\mathtt{unfocus}}}
27 \newcommand{\SKIP}{\MATHTT{skip}}
28 \newcommand{\TACTIC}[1]{\ensuremath{\mathtt{tactic}~#1}}
30 \newcommand{\APPLY}[1]{\ensuremath{\mathtt{apply}~\mathit{#1}}}
32 \newcommand{\GOAL}{\MATHIT{goal}}
33 \newcommand{\SWITCH}{\MATHIT{switch}}
34 \newcommand{\LIST}{\MATHTT{list}}
35 \newcommand{\INT}{\MATHTT{int}}
36 \newcommand{\OPEN}{\MATHTT{Open}}
37 \newcommand{\CLOSED}{\MATHTT{Closed}}
39 \newcommand{\SEMOP}[1]{|[#1|]}
40 \newcommand{\TSEMOP}[1]{{}_t|[#1|]}
41 \newcommand{\SEM}[3][\xi]{\SEMOP{#2}_{{#1},{#3}}}
42 \newcommand{\ENTRY}[4]{\langle#1,#2,#3,#4\rangle}
43 \newcommand{\TSEM}[3]{\TSEMOP{#1}_{#2,#3}}
45 \newcommand{\GIN}[1][1]{\ensuremath{[l_{#1};\cdots;l_n]}}
47 \newcommand{\ZEROPOS}{\MATHIT{zero\_pos}}
48 \newcommand{\INITPOS}{\MATHIT{init\_pos}}
49 \newcommand{\ISFRESH}{\MATHIT{is\_fresh}}
50 \newcommand{\FILTER}{\MATHIT{filter}}
51 \newcommand{\FILTEROPEN}{\MATHIT{filter\_open}}
52 \newcommand{\ISOPEN}{\MATHIT{is\_open}}
53 \newcommand{\DEEPCLOSE}{\MATHIT{deep\_close}}
54 \newcommand{\REMOVEGOALS}{\MATHIT{remove\_goals}}
55 \newcommand{\GOALS}{\MATHIT{goals}}
57 \newcommand{\BRANCHTAG}{\ensuremath{\mathtt{B}}}
58 \newcommand{\FOCUSTAG}{\ensuremath{\mathtt{F}}}
60 \newlength{\sidecondlen}
61 \setlength{\sidecondlen}{2cm}
72 S & ::= & & \mbox{(\textbf{continuationals})}\\
73 & & \TACTIC{T} & \mbox{(tactic)}\\[2ex]
74 & | & \DOT & \mbox{(dot)} \\
75 & | & \SEMICOLON & \mbox{(semicolon)} \\
76 & | & \BRANCH & \mbox{(branch)} \\
77 & | & \SHIFT & \mbox{(shift)} \\
78 & | & \POS{i} & \mbox{(relative positioning)} \\
79 & | & \MERGE & \mbox{(merge)} \\[2ex]
80 & | & \FOCUS{g_1,\dots,g_n} & \mbox{(absolute positioning)} \\
81 & | & \UNFOCUS & \mbox{(unfocus)} \\[2ex]
82 & | & S ~ S & \mbox{(sequential composition)} \\[2ex]
83 T & : := & & \mbox{(\textbf{tactics})}\\
84 & & \SKIP & \mbox{(skip)} \\
85 & | & \mathtt{reflexivity} & \\
86 & | & \mathtt{apply}~t & \\
95 \xi & & & \mbox{(proof status)} \\
96 \mathit{goal} & & & \mbox{(proof goal)} \\[2ex]
98 \SWITCH & = & \OPEN~\mathit{goal} ~ | ~ \CLOSED~\mathit{goal} & \\
99 \mathit{locator} & = & \INT\times\SWITCH & \\
100 \mathit{tag} & = & \BRANCHTAG ~ | ~ \FOCUSTAG \\[2ex]
102 \Gamma & = & \mathit{locator}~\LIST & \mbox{(context)} \\
103 \tau & = & \mathit{locator}~\LIST & \mbox{(todo)} \\
104 \kappa & = & \mathit{locator}~\LIST & \mbox{(dot's future)} \\[2ex]
106 \mathit{stack} & = & (\Gamma\times\tau\times\kappa\times\mathit{tag})~\LIST
109 \mathit{status} & = & \xi\times\mathit{stack} \\
113 \paragraph{Utilities}
115 \item $\ZEROPOS([g_1;\cdots;g_n]) =
116 [\langle 0,\OPEN~g_1\rangle;\cdots;\langle 0,\OPEN~g_n\rangle]$
117 \item $\INITPOS([\langle i_1,s_1\rangle;\cdots;\langle i_n,s_n\rangle]) =
118 [\langle 1,\OPEN~s_1\rangle;\cdots;\langle n,\OPEN~s_n\rangle]$
122 \mathit{true} & \mathrm{if} ~ s = \langle n, \OPEN~g\rangle\land n > 0 \\
123 \mathit{false} & \mathrm{otherwise} \\
126 \item $\FILTEROPEN(\mathit{locs})=
129 [] & \mathrm{if}~\mathit{locs} = [] \\
130 \langle i,\OPEN~g\rangle :: \FILTEROPEN(\mathit{tl})
131 & \mathrm{if}~\mathit{locs} = \langle i,\OPEN~g\rangle :: \mathit{tl} \\
132 \FILTEROPEN(\mathit{tl})
133 & \mathrm{if}~\mathit{locs} = \mathit{hd} :: \mathit{tl} \\
136 \item $\REMOVEGOALS(G,\mathit{locs}) =
139 [] & \mathrm{if}~\mathit{locs} = [] \\
140 \REMOVEGOALS(G,\mathit{tl})
141 & \mathrm{if}~\mathit{locs} = \langle i,\OPEN~g\rangle :: \mathit{tl}
143 hd :: \REMOVEGOALS(G,\mathit{tl})
144 & \mathrm{if}~\mathit{locs} = \mathit{hd} :: \mathit{tl} \\
147 \item $\DEEPCLOSE(G,S)$: (intuition) given a set of goals $G$ and a stack $S$
148 it returns a new stack $S'$ identical to the given one with the exceptions
149 that each locator whose goal is in $G$ is marked as closed in $\Gamma$ stack
150 components and removed from $\tau$ and $\kappa$ components.
151 \item $\GOALS(S)$: (inutition) return all goals appearing in whatever position
152 on a given stack $S$.
155 \paragraph{Invariants}
157 \item $\forall~\mathrm{entry}~\ENTRY{\Gamma}{\tau}{\kappa}{t}, \forall s
158 \in\tau\cup\kappa, \exists g, s = \OPEN~g$ (each locator on the stack in
159 $\tau$ and $\kappa$ components has an \OPEN~switch).
160 \item Unless \FOCUS{} is used the stack contains no duplicate goals.
163 \subsection{Semantics}
167 \SEMOP{\cdot} & : & C -> \mathit{status} -> \mathit{status} &
168 \mbox{(continuationals semantics)} \\
169 \TSEMOP{\cdot} & : & T -> \xi -> \SWITCH ->
170 \xi\times\GOAL~\LIST\times\GOAL~\LIST & \mbox{(tactics semantics)} \\
176 \mathit{apply\_tac} & : & T -> \xi -> \GOAL ->
177 \xi\times\GOAL~\LIST\times\GOAL~\LIST
183 \TSEM{T}{\xi}{\OPEN~g} & = & \mathit{apply\_tac}(T,\xi,n) & T\neq\SKIP\\
184 \TSEM{\SKIP}{\xi}{\CLOSED~g} & = & \langle \xi, [], [g]\rangle &
191 \SEM{\TACTIC{T}}{\ENTRY{\GIN}{\tau}{\kappa}{t}::S}
195 \ENTRY{\Gamma'}{\tau'}{\kappa'}{t}
196 % \ENTRY{\ZEROPOS(G^o_n)}{\tau\setminus G^c_n}{\kappa\setminus G^o_n}{t}
197 :: \DEEPCLOSE(G^c_n,S)
200 \multicolumn{3}{l}{\hspace{\sidecondlen}\mathit{where} ~
201 \Gamma' = \ZEROPOS(G^o_n)
202 \land \tau' = \REMOVEGOALS(G^c_n,\tau)
203 \land \kappa' = \REMOVEGOALS(G^o_n,\kappa)
206 \multicolumn{3}{l}{\hspace{\sidecondlen}\mathit{and} ~
209 \langle\xi_0, G^o_0, G^c_0\rangle & = & \langle\xi, [], []\rangle \\
210 \langle\xi_{i+1}, G^o_{i+1}, G^c_{i+1}\rangle
212 & \langle\xi_i, G^o_i, G^c_i\rangle
213 & l_{i+1}\in G^c_i \\
214 \langle\xi_{i+1}, G^o_{i+1}, G^c_{i+1}\rangle
216 & \langle\xi, (G^o_i\setminus G^c)\cup G^o, G^c_i\cup G^c\rangle
217 & l_{i+1}\not\in G^c_i \\[1ex]
218 & & \mathit{where} ~ \langle\xi,G^o,G^c\rangle=\TSEM{T}{\xi_i}{l_{i+1}} \\
224 \SEM{~\DOT~}{\ENTRY{\Gamma}{\tau}{\kappa}{t}::S}
226 & \langle \xi, \ENTRY{l_1}{\tau}{\GIN[2]\cup\kappa}{t}::S \rangle
228 & & \mathrm{where} ~ \FILTEROPEN(\Gamma)=\GIN \land n\geq 1
231 \SEM{~\DOT~}{\ENTRY{\Gamma}{\tau}{l::\kappa}{t}::S}
233 & \langle \xi, \ENTRY{[l]}{\tau}{\kappa}{t}::S \rangle
235 & & \mathrm{where} ~ \FILTEROPEN(\Gamma)=[]
238 \SEM{~\SEMICOLON~}{S} & = & \langle \xi, S \rangle \\[1ex]
240 \SEM{~\BRANCH~}{\ENTRY{\GIN}{\tau}{\kappa}{t}::S}
243 & \langle\xi, \ENTRY{[l_1']}{[]}{[]}{\BRANCHTAG}
244 ::\ENTRY{[l_2';\cdots;l_n']}{\tau}{\kappa}{t}::S
246 & & \mathrm{where} ~ n\geq 2 ~ \land ~ \INITPOS(\GIN)=[l_1';\cdots;l_n']
250 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}::\ENTRY{\GIN}{\tau'}{\kappa'}{t'}
254 \xi, \ENTRY{[l_1]}{\tau\cup\FILTEROPEN(\Gamma)}{[]}{\BRANCHTAG}
255 ::\ENTRY{\GIN[2]}{\tau'}{\kappa'}{t'}::S
258 & & \mathrm{where} ~ n\geq 1
262 {\ENTRY{[l]}{[]}{[]}{\BRANCHTAG}::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}::S}
264 & \langle \xi, \ENTRY{[l_i]}{[]}{[]}{\BRANCHTAG}
265 ::\ENTRY{l :: (\Gamma'\setminus [l_i])}{\tau'}{\kappa'}{t'}::S \rangle
267 & & \mathrm{where} ~ \langle i,l'\rangle = l_i\in \Gamma'~\land~\ISFRESH(l)
271 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}
272 ::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}::S}
274 & \langle \xi, \ENTRY{[l_i]}{[]}{[]}{\BRANCHTAG}
275 ::\ENTRY{\Gamma'\setminus [l_i]}{\tau'\cup\FILTEROPEN(\Gamma)}{\kappa'}{t'}::S
278 & & \mathrm{where} ~ \langle i, l'\rangle = l_i\in \Gamma'
282 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}
286 \ENTRY{\tau\cup\FILTEROPEN(\Gamma)\cup\Gamma'\cup\kappa}{\tau'}{\kappa'}{t'}
291 \SEM{\FOCUS{g_1,\dots,g_n}}{S}
293 & \langle \xi, \ENTRY{[\OPEN~g_1;\cdots;\OPEN~g_n]}{[]}{[]}{\FOCUSTAG}
298 \forall i=1,\dots,n,~g_i\in\GOALS(S)
301 \SEM{\UNFOCUS}{\ENTRY{[]}{[]}{[]}{\FOCUSTAG}::S}
303 & \langle \xi, S\rangle \\[2ex]