]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/tactics/doc/main.tex
restated ...
[helm.git] / helm / ocaml / tactics / doc / main.tex
1 \documentclass[a4paper,draft]{article}
2
3 \usepackage{a4wide}
4 \usepackage{pifont}
5 \usepackage{semantic}
6 \usepackage{stmaryrd}
7
8 \newcommand{\MATITA}{\ding{46}\textsf{\textbf{Matita}}}
9
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}}
15
16 \newcommand{\DOT}{\mbox{\textbf{.}}}
17 \newcommand{\SEMICOLON}{\mbox{\textbf{;}}}
18 \newcommand{\BRANCH}{\mbox{\textbf{[}}}
19 \newcommand{\SHIFT}{\mbox{\textbf{\textbar}}}
20 \newcommand{\MERGE}{\mbox{\textbf{]}}}
21 \newcommand{\APPLY}[1]{\ensuremath{\mathtt{apply}~\mathit{#1}}}
22 \newcommand{\SKIP}{\ensuremath{\mathtt{skip}}}
23 \newcommand{\TACTICAL}[1]{\ensuremath{\mathtt{tactical}~\mathit{#1}}}
24 \newcommand{\SELECT}[2]{\ensuremath{\mathtt{select} ~ #1 ~ #2}}
25
26 \newcommand{\GOAL}{\ensuremath{\mathit{goal}}}
27 \newcommand{\GOALSWITCH}{\ensuremath{\mathit{goal\_switch}}}
28 \newcommand{\LIST}{\ensuremath{\mathtt{list}}}
29 \newcommand{\BOOL}{\ensuremath{\mathtt{bool}}}
30 \newcommand{\STACK}{\ensuremath{\mathtt{stack}}}
31 \newcommand{\OPEN}[1]{\ensuremath{\mathtt{Open}~#1}}
32 \newcommand{\CLOSED}[1]{\ensuremath{\mathtt{Closed}~#1}}
33
34 \newcommand{\SEMOP}[1]{|[#1|]}
35 \newcommand{\TSEMOP}[1]{{}_t|[#1|]}
36 \newcommand{\SEM}[5]{\SEMOP{#1}_{#2,#3,#4,#5}}
37 \newcommand{\TSEM}[3]{\TSEMOP{#1}_{#2,#3}}
38
39 \newcommand{\FUN}[2]{\ensuremath{\mathit{#1}(#2)}}
40 \newcommand{\FILTERFUN}[2]{\FUN{filter}{#1,#2}}
41 \newcommand{\MAPFUN}[2]{\FUN{map}{#1,#2}}
42 \newcommand{\DEEPMAPFUN}[2]{\FUN{deep\_map}{#1,#2}}
43 \newcommand{\ISOPENFUN}{\ensuremath{\mathit{is\_open}}}
44 \newcommand{\CLOSEFUN}{\ensuremath{\mathit{close}}}
45 \newcommand{\GOALOFFUN}{\ensuremath{\mathit{goal\_of}}}
46 \newcommand{\DEEPCLOSEFUN}[2]{\FUN{deep\_close}{#1,#2}}
47
48 \begin{document}
49 \maketitle
50
51 \section{Foo}
52
53 \subsection{Language}
54
55 \[
56 \begin{array}{rcll}
57  C & ::= & & \mbox{(\textbf{continuationals})} \\
58    &     & C ~ \DOT & \mbox{(dot)} \\
59    &  |  & C ~ \SEMICOLON ~ C & \mbox{(semicolon)} \\
60    &  |  & \BRANCH & \mbox{(branch)} \\
61    &  |  & \SHIFT & \mbox{(shift)} \\
62    &  |  & \MERGE & \mbox{(merge)} \\
63    &  |  & \SELECT{n_1,\dots,n_k}{C} & \mbox{(select)} \\
64    &  |  & \TACTICAL{T} & \mbox{(tactical)} \\[2ex]
65
66  T & ::= & & \mbox{(\textbf{tacticals})} \\
67    &     & \APPLY{tac} & \mbox{(tactic application)} \\
68    &  |  & \SKIP & \mbox{(closed goal skipping)} \\
69 \end{array}
70 \]
71
72 \subsection{Status}
73
74 \[
75 \begin{array}{rcll}
76  \mathit{status} & = & \xi\times\Gamma\times\tau\times\kappa & \\
77  \xi & = & \langle n,\alpha\rangle~\LIST& \mbox{(metasenv)} \\
78  \Gamma & = & \GOALSWITCH~\LIST~\STACK & \mbox{(context)} \\
79  \GOALSWITCH & = & \OPEN{n} \quad | \quad \CLOSED{n} & \\
80  \tau & = & \GOAL~\LIST~\STACK & \mbox{(todo)} \\
81  \kappa & = & \GOAL~\LIST~\STACK & \mbox{(dot continuations)} \\
82 \end{array}
83 \]
84
85 \subsection{Semantics}
86
87 \[
88 \begin{array}{rcll}
89  \SEMOP{\cdot} & : & C -> \mathit{status} -> \mathit{status} &
90   \mbox{(continuationals semantics)} \\
91  \TSEMOP{\cdot} & : & T -> \xi -> \GOALSWITCH ->
92   \xi\times\GOAL~\LIST\times\GOAL~\LIST & \mbox{(tacticals semantics)} \\
93 \end{array}
94 \]
95
96 \[
97 \begin{array}{rcl}
98  \mathit{filter} & : & (\alpha->\BOOL)->\alpha~\LIST->\alpha~\LIST \\
99  \mathit{map} & : & (\alpha->\beta)->\alpha~\LIST->\beta~\LIST \\
100  \mathit{deep\_map} & :
101   & (\alpha->\beta)->\alpha~\LIST~\STACK->\beta~\LIST~\STACK \\
102  \in & : & \alpha->\alpha~\LIST->\BOOL \\
103  \cup & : & \alpha~\LIST->\alpha~\LIST->\alpha~\LIST \\
104  \setminus & : & \alpha~\LIST->\alpha~\LIST->\alpha~\LIST \\
105 \end{array}
106 \]
107
108 \[
109 \begin{array}{rcl}
110  \mathit{apply\_tac} & : & \mathit{tac} -> \xi -> \GOAL ->
111   \xi\times\GOAL~\LIST\times\GOAL~\LIST \\[1ex]
112 %  \ISCLOSEDFUN & : & \GOALSWITCH -> \BOOL \\
113  \ISOPENFUN & : & \GOALSWITCH -> \BOOL \\
114  \CLOSEFUN & : & \GOALSWITCH -> \GOALSWITCH \\[1ex]
115 %  \OPENFUN & : & \GOAL -> \GOALSWITCH \\[1ex]
116  \GOALOFFUN & : & \GOALSWITCH -> \GOAL \\[1ex]
117  \mathit{deep\_close} & :
118  & \GOAL~\LIST -> \GOALSWITCH~\STACK -> \GOALSWITCH~\STACK \\[1ex]
119 \end{array}
120 \]
121
122 \[
123 \begin{array}{rcl}
124  \DEEPCLOSEFUN{G}{\Gamma}
125  & =
126  & \MAPFUN{\mathit{fold}
127   (\lambda g.\lambda acc.
128    \mathit{if}~\GOALOFFUN(g)\in G~\land\ISOPENFUN(g)~
129    \mathit{then}~[]~
130    \mathit{else}~[g]\cup\mathit{acc})
131    []}{\Gamma}
132 \end{array}
133 \]
134
135 \[
136 \begin{array}{rlcc}
137  \TSEM{\APPLY{tac}}{\xi}{\OPEN{n}} & =
138  & \mathit{apply\_tac}(\mathit{tac},\xi,n) & \\
139  \TSEM{\SKIP}{\xi}{\CLOSED{n}} & = & \langle \xi, [], [n]\rangle & \\
140 \end{array}
141 \]
142
143 \[
144 \begin{array}{rcl}
145  \SEM{\TACTICAL{T}}{\xi}{[g_1;\dots;g_n]::\Gamma}{\tau}{\kappa}
146  \quad (n\geq 1)
147  & =
148  & \langle\xi_n,
149  \MAPFUN{\mathtt{Open}}{G^O_n}::\DEEPCLOSEFUN{G^C_n}{\Gamma},
150    \tau\setminus G^C_n,\kappa\setminus G^O_n\rangle
151  \\[1ex]
152
153  \multicolumn{3}{l}{\hspace{2em}\mathit{where} ~
154  \left\{
155  \begin{array}{rcll}
156   \langle\xi_0, G^O_0, G^C_0\rangle & = & \langle\xi, [], []\rangle \\
157   \langle\xi_{i+1}, G^O_{i+1}, G^C_{i+1}\rangle
158   & =
159   & \langle\xi_i, G^O_i, G^C_i\rangle
160   & g_{i+1}\in G^C_i \\
161   \langle\xi_{i+1}, G^O_{i+1}, G^C_{i+1}\rangle
162   & =
163   & \langle\xi, (G^O_i\setminus G^C)\cup G^O, G^C_i\cup G^C\rangle
164   & g_{i+1}\not\in G^C_i \\
165   & & \mathit{where} ~ \langle\xi,G^O,G^C\rangle=\TSEM{T}{\xi_i}{g_{i+1}}
166   \\
167  \end{array}
168  \right.
169  }
170  \\[2ex]
171
172  \SEM{C_1 ~ \SEMICOLON ~ C_2}{\xi}{\Gamma}{\tau}{\kappa}
173  & =
174  & \SEM{C_2}{\xi'}{\Gamma'}{\tau'}{\kappa'}
175  \\[1ex]
176
177  & & \mathit{where} ~
178  \langle\xi',\Gamma',\tau',\kappa',\rangle =
179  \SEM{C_1}{\xi}{\Gamma}{\tau}{\kappa}
180  \\[2ex]
181
182  \SEM{C~\DOT~}{\xi}{\Gamma}{\tau}{\kappa}
183  & =
184  & \langle \xi'', \Gamma'', \tau'', \kappa'' \rangle
185  \\[1ex]
186
187  \multicolumn{3}{l}{\hspace{2em}\mathit{where} ~
188   \langle \xi',G::\Gamma',\tau',K::\kappa' \rangle
189    = \SEM{C}{\xi}{\Gamma}{\tau}{\kappa}}
190  \\[1ex]
191
192  \multicolumn{3}{l}{\hspace{2em}\mathit{and} ~
193  \langle \xi'', \Gamma'', \tau'', \kappa'' \rangle =
194  \left\{
195  \begin{array}{ll}
196   \langle \xi', [g]::\Gamma', \tau', (\MAPFUN{\GOALOFFUN}{G'}\cup K)::\kappa'
197   \rangle
198   & \FILTERFUN{\ISOPENFUN}{G} = g::G'
199   \\
200   \langle \xi', [\mathtt{Open}~n]::\Gamma', \tau', K'::\kappa' \rangle
201   & \FILTERFUN{\ISOPENFUN}{G} = []~\land~K=n::K'
202  \end{array}
203  \right.}
204  \\[2ex]
205
206  \SEM{~\BRANCH~}{\xi}{[g_1;\dots;g_n]::\Gamma}{\tau}{\kappa}
207  \quad (n\geq 2)
208  & =
209  & \langle\xi, [g_1]::[g_2;\dots;g_n]::\Gamma, []::\tau, []::\kappa\rangle
210  \\[2ex]
211
212  \SEM{~\SHIFT~}{\xi}{G::[g_i;\dots;g_n]::\Gamma}{T::\tau}{K::\kappa}
213  & =
214  & \langle\xi,
215    [g_i]::[g_{i+1};\dots;g_n]::\Gamma,
216    \tau'::\tau,
217    []::\kappa\rangle
218  \\[1ex]
219
220  & & \mathit{where} ~
221    \tau' = T\cup\MAPFUN{\GOALOFFUN}{\FILTERFUN{\ISOPENFUN}{G}}\cup K
222  \\[2ex]
223
224  \SEM{~\MERGE~}{\xi}{G::[g_i;\dots;g_n]::\Gamma}{T::\tau}{K::\kappa}
225  & =
226  & \langle \xi, \Gamma'::\Gamma, \tau, \kappa \rangle
227  \\[1ex]
228
229  & & \mathit{where} ~
230    \Gamma' = 
231     T \cup\FILTERFUN{\ISOPENFUN}{G}
232      \cup[g_i;\dots;g_n]
233      \cup\MAPFUN{\mathtt{Open}}{K}
234  \\[2ex]
235
236  \SEM{\SELECT{n_1,\dots,n_k}{C}}{\xi}{\Gamma}{\tau}{\kappa}
237  & = 
238  & \langle \xi',\Gamma',\tau',\kappa' \rangle
239  \\[1ex]
240
241  & & \mathit{where} ~
242  \forall ~ i=1,\dots,k,~\exists ~ \alpha_i,~\langle n_i,\alpha_i\rangle \in \xi
243  \\[1ex]
244
245  & & \mathit{and} ~
246  \langle \xi', []::\Gamma', []::\tau', []::\kappa' \rangle
247  = \SEM{C}{\xi}{\MAPFUN{\mathtt{Open}}{[n_1;\dots;n_k]}::\Gamma}{[]::\tau}{[]::\kappa}
248  \\[2ex]
249
250 \end{array}
251 \]
252
253 \end{document}
254