Debian Codegraph @

texmf-dist/doc/latex/fodot/fodot-doc.tex

raw
1 \documentclass{article}
2
3 \usepackage{hyperref}
4 \usepackage{fodot}
5
6 \newcommand{\pkg}[1]{\texttt{#1}}
7
8 \begin{document}
9
10 \title{The package \pkg{fodot}\thanks{This document corresponds to the
11 version 0.0.1 of \pkg{fodot}, at the date of 2025/08/29.}}
12 \author{Christian Fleiner \\ \texttt{[email protected]}}
13
14 \maketitle
15
16 \begin{abstract}
17 The package \pkg{fodot} provides helpful commands to work with the \fodot language in \LaTeX including syntax highlighting in listings.
18 \end{abstract}
19
20
21 \section{Contributing}
22 Contributions are always welcome. The project is hosted at \url{https://gitlab.com/EAVISE/CFL/fodot-latex}.
23
24 \section{Description}
25 In the following, the capabilities of the package are described and illustrated. The \fodot language itself is not introduced. \fodot\footnote{\url{https://docs.idp-z3.be/en/stable/introduction.html}} is the technical implementation of \fodott\footnote{\url{https://fo-dot.readthedocs.io/en/latest/FO-dot.html}} used in the reasoning engine IDP-Z3\footnote{\url{https://idp-z3.be/}}. Please refer to the official documentation to learn more.
26
27 \subsection{Commands}
28 The following commands are currently supported:
29 \begin{enumerate}
30 \item Type \verb|\fodot| for: \fodot. \textit{(partial implementation of \fodott)}
31 \item Type \verb|\fodott| for: \fodott. \textit{(formal knowledge representation language)}
32 \end{enumerate}
33
34
35 \subsection{FODOT Syntax Highlighting}
36
37 There are two styles to highlight \fodot code in listings.
38 \fodot code must be always copied in ASCII format.
39 \texttt{fodot} replaces operators with their UTF-8 symbol.
40 \texttt{fodotASCII} keeps the ASCII representations.
41
42 There are a few bugs that require workarounds:
43 \begin{itemize}
44 \item \verb|*| is somehow not recognized. Replace \verb|*| with \texttt{TIMES} in listing.
45 \item \verb|=<| is highlighted but not replaced (while \verb|<=| would work). Instead, replace \verb|=<| with \verb|=&lt;| in listing (not relevant for \texttt{fodotASCII})
46 \end{itemize}
47
48 The syntax highlighter does not support patterns to highlight URLs.
49
50 See the following templates for each style:
51 \begin{quote}
52 \verb|\begin{lstlisting}[style=fodot]| \\
53 \ldots \\
54 \verb|\end{lstlisting}|
55 \end{quote}
56
57 \begin{quote}
58 \verb|\begin{lstlisting}[style=fodotASCII]| \\
59 \ldots \\
60 \verb|\end{lstlisting}|
61 \end{quote}
62
63 \subsubsection{Examples: Fodot Style}
64 \textbf{Code snippet A}
65 \begin{lstlisting}[style=fodot]
66 vocabulary {
67 // this is a single-line comment
68 type Method := {Nail, Glue, Screw}
69 type Wall := {Brick, Wood, Tile}
70 [this is an annotation]
71 type Difficulty := {1..3}
72
73 /*
74 this is a block comment
75 */
76 wall : () -> Wall
77 method: () -> Method
78 hole : () -> Bool
79 weight: () -> Int
80 difficulty : () -> Difficulty
81 }
82 theory {
83 weight() > 0.
84 method() = Nail => weight() =&lt; 25.
85 method() = Screw => weight() =&lt; 40.
86 method() = Glue => weight() =&lt; 15.
87
88 hole() <=> method() = Nail | method() = Screw.
89 wall() = Tile => ~hole().
90
91 { difficulty() = 1 <- method() = Glue.
92 difficulty() = 2 <- method() = Nail.
93 difficulty() = 3 <- method() = Screw.}
94 }
95 display {
96 view() = expanded.
97 }
98
99 \end{lstlisting}
100 \newpage
101 \textbf{Code Snippet B}
102 \begin{lstlisting}[style=fodot]
103 @prefix we: <http://www.example.org/whatever#>.
104 vocabulary V {
105 @prefix se: <http://www.example.org/somethingelse#_url>.
106 type T
107 type T := {c1, c2, c3}
108 type T := constructed from {c1, c2(T1, f:T2)}
109 type T := {1,2,3} <: Int
110 type T := {1..3} <: Int
111 type we::T
112 type <http://www.example.org/foo#Type>
113
114 p : () -> Bool
115 p1, p2 : T1 TIMES T2 -> Bool
116 f: total T -> T
117 f: T * T -> T (domain: p, codomain: q)
118 f: partial TTIMEST -> T
119 f1, f2: Concept[T1->T2] -> T
120
121 [this is the intended meaning of p]
122 p : () -> Bool
123
124 var x in T
125 import W
126 }
127
128 theory T:V {
129 (~p1()&p2() | p3() => p4() <=> p5()) <= p6().
130 p(f1(f2())).
131 f1() < f2() =&lt; f3() = f4() >= f5() > f6().
132 f() ~= c.
133 !x,y in T: p(x,y).
134 !x in p, (y,z) in q: q(x,x) | p(y) | p(z).
135 ?x in Concept[()->Bool]: $(x)().
136 ?x: p(x). # if var x declared in voc
137 ?>1 x in T: p(x).
138
139 f() in {1,2,3}.
140 f() = #{xinT: p(x)}.
141 f() = min{ f(x) | x in T: p(x) }.
142 f() = sum{{ f(x) | x in T: p(x) }}.
143 if p1() then p2() else p3().
144 f1() = if p() then f2() else f3().
145
146 p := {1,2,3}.
147 p(#2020-01-01) is enumerated.
148 p(#TODAY) is not enumerated.
149
150 { p(1). }
151 { (co-induction)
152 !xinT: p1(x) <- p2(x).
153 f(1)=1.
154 !x: f(x)=1 <- p(x).
155 !x: f(x):=1 <- p(x).
156 }
157
158 [this is the intended meaning of the rule]
159 p().
160 }
161
162 structure S:V {
163 p := false.
164 p := {1,2,3}.
165 p := {0..9, 100}.
166 p := {#2021-01-01}.
167 p := {(1,2), (3,4)}.
168 p := {
169 1 2
170 3 4
171 }.
172
173 f := 1.
174 f := {->1} .
175 f := {1->1, 2->2}.
176 f := {(1,2)->3} else 2.
177 f :> {(1,2)->3}.
178 }
179
180 display {
181 goal_symbol := {`p1, `p2}.
182 hide(`p).
183 expand := {`p}.
184 view() = expanded.
185 optionalPropagation().
186 }
187
188 procedure main() {
189 pretty_print(model_check (T,S))
190 pretty_print(model_expand (T,S))
191 pretty_print(model_propagate(T,S))
192 pretty_print(minimize(T,S, term="cost()"))
193 }
194 \end{lstlisting}
195 \newpage
196 \subsubsection{Examples: FodotASCII Style}
197 \textbf{Code Snippet A}
198 \begin{lstlisting}[style=fodotASCII]
199 vocabulary {
200 // this is a single-line comment
201 type Method := {Nail, Glue, Screw}
202 type Wall := {Brick, Wood, Tile}
203 [this is an annotation]
204 type Difficulty := {1..3}
205
206 /*
207 this is a block comment
208 */
209 wall : () -> Wall
210 method: () -> Method
211 hole : () -> Bool
212 weight: () -> Int
213 difficulty : () -> Difficulty
214 }
215 theory {
216 weight() > 0.
217 method() = Nail => weight() =&lt; 25.
218 method() = Screw => weight() =< 40.
219 method() = Glue => weight() =< 15.
220
221 hole() <=> method() = Nail | method() = Screw.
222 wall() = Tile => ~hole().
223
224 { difficulty() = 1 <- method() = Glue.
225 difficulty() = 2 <- method() = Nail.
226 difficulty() = 3 <- method() = Screw.}
227 }
228 display {
229 view() = expanded.
230 }
231
232 \end{lstlisting}
233 \newpage
234 \textbf{Code Snippet B}
235 \begin{lstlisting}[style=fodotASCII]
236
237 @prefix we: <http://www.example.org/whatever#>.
238 vocabulary V {
239 @prefix se: <http://www.example.org/somethingelse#_url>.
240 type T
241 type T := {c1, c2, c3}
242 type T := constructed from {c1, c2(T1, f:T2)}
243 type T := {1,2,3} <: Int
244 type T := {1..3} <: Int
245 type we::T
246 type <http://www.example.org/foo#Type>
247
248 p : () -> Bool
249 p1, p2 : T1 TIMES T2 -> Bool
250 f: total T -> T
251 f: T * T -> T (domain: p, codomain: q)
252 f: partial TTIMEST -> T
253 f1, f2: Concept[T1->T2] -> T
254
255 [this is the intended meaning of p]
256 p : () -> Bool
257
258 var x in T
259 import W
260 }
261
262 theory T:V {
263 (~p1()&p2() | p3() => p4() <=> p5()) <= p6().
264 p(f1(f2())).
265 f1() < f2() =< f3() = f4() >= f5() > f6().
266 f() ~= c.
267 !x,y in T: p(x,y).
268 !x in p, (y,z) in q: q(x,x) | p(y) | p(z).
269 ?x in Concept[()->Bool]: $(x)().
270 ?x: p(x). # if var x declared in voc
271 ?>1 x in T: p(x).
272
273 f() in {1,2,3}.
274 f() = #{xinT: p(x)}.
275 f() = min{ f(x) | x in T: p(x) }.
276 f() = sum{{ f(x) | x in T: p(x) }}.
277 if p1() then p2() else p3().
278 f1() = if p() then f2() else f3().
279
280 p := {1,2,3}.
281 p(#2020-01-01) is enumerated.
282 p(#TODAY) is not enumerated.
283
284 { p(1). }
285 { (co-induction)
286 !xinT: p1(x) <- p2(x).
287 f(1)=1.
288 !x: f(x)=1 <- p(x).
289 !x: f(x):=1 <- p(x).
290 }
291
292 [this is the intended meaning of the rule]
293 p().
294 }
295
296 structure S:V {
297 p := false.
298 p := {1,2,3}.
299 p := {0..9, 100}.
300 p := {#2021-01-01}.
301 p := {(1,2), (3,4)}.
302 p := {
303 1 2
304 3 4
305 }.
306
307 f := 1.
308 f := {->1} .
309 f := {1->1, 2->2}.
310 f := {(1,2)->3} else 2.
311 f :> {(1,2)->3}.
312 }
313
314 display {
315 goal_symbol := {`p1, `p2}.
316 hide(`p).
317 expand := {`p}.
318 view() = expanded.
319 optionalPropagation().
320 }
321
322 procedure main() {
323 pretty_print(model_check (T,S))
324 pretty_print(model_expand (T,S))
325 pretty_print(model_propagate(T,S))
326 pretty_print(minimize(T,S, term="cost()"))
327 }
328 \end{lstlisting}
329
330 \end{document}