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{open\_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,s_1\rangle;\cdots;\langle n,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$, appearing in an \OPEN{} switch.
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.
161 \item $\forall~\mathrm{locator}~l\in\Gamma \mbox{(with the exception of the
162 top-level $\Gamma$)}, \ISFRESH(l)$.
165 \subsection{Semantics}
169 \SEMOP{\cdot} & : & C -> \mathit{status} -> \mathit{status} &
170 \mbox{(continuationals semantics)} \\
171 \TSEMOP{\cdot} & : & T -> \xi -> \SWITCH ->
172 \xi\times\GOAL~\LIST\times\GOAL~\LIST & \mbox{(tactics semantics)} \\
178 \mathit{apply\_tac} & : & T -> \xi -> \GOAL ->
179 \xi\times\GOAL~\LIST\times\GOAL~\LIST
185 \TSEM{T}{\xi}{\OPEN~g} & = & \mathit{apply\_tac}(T,\xi,n) & T\neq\SKIP\\
186 \TSEM{\SKIP}{\xi}{\CLOSED~g} & = & \langle \xi, [], [g]\rangle &
193 \SEM{\TACTIC{T}}{\ENTRY{\GIN}{\tau}{\kappa}{t}::S}
197 \ENTRY{\Gamma'}{\tau'}{\kappa'}{t}
198 % \ENTRY{\ZEROPOS(G^o_n)}{\tau\setminus G^c_n}{\kappa\setminus G^o_n}{t}
199 :: \DEEPCLOSE(G^c_n,S)
202 \multicolumn{3}{l}{\hspace{\sidecondlen}\mathit{where} ~ n\geq 1}
204 \multicolumn{3}{l}{\hspace{\sidecondlen}\mathit{and} ~
205 \Gamma' = \ZEROPOS(G^o_n)
206 \land \tau' = \REMOVEGOALS(G^c_n,\tau)
207 \land \kappa' = \REMOVEGOALS(G^o_n,\kappa)
210 \multicolumn{3}{l}{\hspace{\sidecondlen}\mathit{and} ~
213 \langle\xi_0, G^o_0, G^c_0\rangle & = & \langle\xi, [], []\rangle \\
214 \langle\xi_{i+1}, G^o_{i+1}, G^c_{i+1}\rangle
216 & \langle\xi_i, G^o_i, G^c_i\rangle
217 & l_{i+1}\in G^c_i \\
218 \langle\xi_{i+1}, G^o_{i+1}, G^c_{i+1}\rangle
220 & \langle\xi, (G^o_i\setminus G^c)\cup G^o, G^c_i\cup G^c\rangle
221 & l_{i+1}\not\in G^c_i \\[1ex]
222 & & \mathit{where} ~ \langle\xi,G^o,G^c\rangle=\TSEM{T}{\xi_i}{l_{i+1}} \\
228 \SEM{~\DOT~}{\ENTRY{\Gamma}{\tau}{\kappa}{t}::S}
230 & \langle \xi, \ENTRY{l_1}{\tau}{\GIN[2]\cup\kappa}{t}::S \rangle
232 & & \mathrm{where} ~ \FILTEROPEN(\Gamma)=\GIN \land n\geq 1
235 \SEM{~\DOT~}{\ENTRY{\Gamma}{\tau}{l::\kappa}{t}::S}
237 & \langle \xi, \ENTRY{[l]}{\tau}{\kappa}{t}::S \rangle
239 & & \mathrm{where} ~ \FILTEROPEN(\Gamma)=[]
242 \SEM{~\SEMICOLON~}{S} & = & \langle \xi, S \rangle \\[1ex]
244 \SEM{~\BRANCH~}{\ENTRY{\GIN}{\tau}{\kappa}{t}::S}
247 & \langle\xi, \ENTRY{[l_1']}{[]}{[]}{\BRANCHTAG}
248 ::\ENTRY{[l_2';\cdots;l_n']}{\tau}{\kappa}{t}::S
250 & & \mathrm{where} ~ n\geq 2 ~ \land ~ \INITPOS(\GIN)=[l_1';\cdots;l_n']
254 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}::\ENTRY{\GIN}{\tau'}{\kappa'}{t'}
258 \xi, \ENTRY{[l_1]}{\tau\cup\FILTEROPEN(\Gamma)}{[]}{\BRANCHTAG}
259 ::\ENTRY{\GIN[2]}{\tau'}{\kappa'}{t'}::S
262 & & \mathrm{where} ~ n\geq 1
266 {\ENTRY{[l]}{[]}{[]}{\BRANCHTAG}::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}::S}
268 & \langle \xi, \ENTRY{[l_i]}{[]}{[]}{\BRANCHTAG}
269 ::\ENTRY{l :: (\Gamma'\setminus [l_i])}{\tau'}{\kappa'}{t'}::S \rangle
271 & & \mathrm{where} ~ \langle i,l'\rangle = l_i\in \Gamma'~\land~\ISFRESH(l)
275 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}
276 ::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}::S}
278 & \langle \xi, \ENTRY{[l_i]}{[]}{[]}{\BRANCHTAG}
279 ::\ENTRY{\Gamma'\setminus [l_i]}{\tau'\cup\FILTEROPEN(\Gamma)}{\kappa'}{t'}::S
282 & & \mathrm{where} ~ \langle i, l'\rangle = l_i\in \Gamma'
286 {\ENTRY{\Gamma}{\tau}{\kappa}{\BRANCHTAG}::\ENTRY{\Gamma'}{\tau'}{\kappa'}{t'}
290 \ENTRY{\tau\cup\FILTEROPEN(\Gamma)\cup\Gamma'\cup\kappa}{\tau'}{\kappa'}{t'}
295 \SEM{\FOCUS{g_1,\dots,g_n}}{S}
297 & \langle \xi, \ENTRY{\ZEROPOS([g_1;\cdots;g_n])}{[]}{[]}{\FOCUSTAG}
302 \forall i=1,\dots,n,~g_i\in\GOALS(S)
305 \SEM{\UNFOCUS}{\ENTRY{[]}{[]}{[]}{\FOCUSTAG}::S}
307 & \langle \xi, S\rangle \\[2ex]