Commit 78fd7bea authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

org: Add a Concepts page.

* doc/org/ New file.
* doc/ Add it.
* doc/org/ Add anchor.
* doc/org/, doc/org/ Add links to
* doc/org/spot.css: Set up boxes for implementation details.
* NEWS: Mention the new page.
parent 2364ff81
New in spot 1.99.7a (not yet released)
Nothing yet.
* There is a new page giving informal illustrations (and extra
pointers) for some concepts used in Spot.
New in spot 1.99.7 (2016-01-15)
## -*- coding: utf-8 -*-
## Copyright (C) 2010, 2011, 2013, 2014, 2015 Laboratoire de Recherche et
## Développement de l'Epita (LRDE).
## Copyright (C) 2010, 2011, 2013, 2014, 2015, 2016 Laboratoire de
## Recherche et Développement de l'Epita (LRDE).
## Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris
## 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
## Université Pierre et Marie Curie.
......@@ -68,6 +68,7 @@ ORG_FILES = \
org/ \
org/ \
org/ \
org/ \
org/ \
org/ \
org/ \
# -*- coding: utf-8 -*-
#+TITLE: Concepts
#+HTML_LINK_UP: index.html
This page documents some of the concepts used in Spot, and whose
knowledge is usually assumed throughout the documentation. The
presentation is informal on purpose.
* Atomic proposition (AP)
An /atomic proposition/ is a named Boolean variable that represents a
simple property that must be true or false. It usually represents
some property of a system. For instance =light_on= and =door_open=
could be the names of two atomic propositions that are respectively
true if the light is on and the door open, and false otherwise.
Atomic propositions are used to construct temporal logic formulas (see
below) to specify properties of the system: for instance we might want
to state that /whenever the the door is open, the light should be on/.
We could write that as the [[#ltl][LTL formula]] =G(door_open -> light_on)= in
which =G= is a temporal operator that means /always/.
Atomic propositions are also used to form the [[#boolean][Boolean formulas]] that
label the edges of automata.
* Boolean formula
:CUSTOM_ID: boolean
A /Boolean formula/ is formed from [[#ap][atomic propositions]], the Boolean
constants true and false, and standard Boolean operators like /and/,
/or/, /implies/, /xor/, etc.
* Binary Decision Diagrams (BDD)
A Binary Decision Diagram is a data structure for efficient
manipulation of [[#boolean][Boolean formulas]].
BDDs correspond to a kind of /if-then-else normal form/ for Boolean
formulas. If we fix the order in which the atomic propositions will
be tested, that normal form is unique. BDDs are stored as directed
acyclic graphs with sharing of subformulas.
For further information about BDDs, read for instance [[][Henrik Reif
Andersen's lecture notes]].
In Spot, BDDs are one way to represent Boolean formulas, and in
particular, they are used to labels the edges of [[#buchi][automata]]. Spot uses a
customized version of [[][the BuDDy library]] for manipulating BDDs.
* ω-word
:CUSTOM_ID: word
An ω-word (omega-word) is a word of infinite length. In our context,
each letter is used to describe the state of a system at a given time,
and the sequence of letters shows the evolution of the system as the
(discrete) time is incremented.
If the set $AP$ of [[#ap][atomic propositions]] is fixed, an ω-word over $AP$
is an infinite sequence of subsets of $AP$. In other words, there are
$2^{|AP|}$ possible letters to choose from, and these letters denote
the set of atomic propositions that are true at a given instant.
For instance if $AP=\{a,b,c\}$, the infinite sequence
\[\{a,b\};\{a\};\{a,b\};\{a\};\{a,b\};\{a\};\ldots\] is an example of
ω-word over $AP$. This particular ω-word can be interpreted as the
following scenario: atomic proposition $a$ is always true, $b$ is true
at each other instant, and $c$ is always false.
Note that instead of using sets of atomic propositions, it is equivalent
to write that word using [[][minterms]] over $AP$:
\[(a\land b\land \bar c);(a\land \bar b\land \bar c);
(a\land b\land \bar c);(a\land \bar b\land \bar c);
(a\land b\land \bar c);(a\land \bar b\land \bar c);\ldots\]
* ω-Automaton
:CUSTOM_ID: automaton
An ω-automaton is used to represent sets of ω-word.
Those look like the classical [[][Nondeterministic Finite Automata]] in the
sense that they also have states and transitions. However ω-automata
recognize [[#word][ω-words]] instead of finite words. In this context, the
notion of /final state/ makes no sense, and is replaced by the notion
of [[#acceptance-condition][acceptance condition]]: a run of the automaton (i.e., an infinite
sequence alternating states and edges in a way that is compatible with
the structure of the automaton) is /accepting/ if it satisfies the
constraint given by the acceptance condition.
In Spot, ω-automata have their edges labeled by [[#boolean][Boolean formulas]]
represented using [[#bdd][BDDs]]. An ω-word is accepted by an ω-automaton if
there exists an accepting run whose labels (those Boolean formulas)
are compatible with the minterms used as letters in the word.
The /language/ of an automaton is the set of ω-words it accepts.
There are many kinds of ω-Automata and they mostly differ by their
[[#acceptance-condition][acceptance condition]]. The different types of acceptance condition,
and whether the automata are deterministic or can affect their
expressive power.
One of the simplest and most common type of ω-Automata is the [[#buchi][Büchi
automaton]] described next.
* Büchi automaton
:CUSTOM_ID: buchi
A Büchi automaton is a simple kind of [[#automaton][ω-Automaton]] in which a run is
accepting iff it visits some /accepting state/ infinitely often.
Those accepting states are often denoted using a double circle.
For instance here is a Büchi automaton that accepts only words in
which $a$ is always true, and $b$ is true infinitely often.
#+NAME: buchi-example1
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'G(a) & GF(b)' -B -d
#+BEGIN_SRC dot :file concept-buchi1.png :cmdline -Tpng :var txt=buchi-example1 :exports results
The above automaton would accept the [[#word][ω-word we used previously as an
As a more concrete example, here is a (complete) Büchi automaton for
the [[#ltl][LTL formula]] =G(door_open -> light_on)= that specifies that
=light_on= should be true whenever =door_open= is true.
#+NAME: buchi-example2
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'G(door_open -> light_on)' -d -C
#+BEGIN_SRC dot :file concept-buchi2.png :cmdline -Tpng :var txt=buchi-example2 :exports results
The =1= displayed on the edge that loops on state =1= should be
read as /true/, i.e., the Boolean formula that accepts
any valuation of the atomic propositions.
The above automaton is complete: any possible ω-word over
$AP=\{\mathit{door\_open}, \mathit{light\_on}\}$ is recognized by some
run. But not all those runs are accepting. In fact, there is only one
run that is accepting: the one that loops continuously on state 0.
All the remaining runs eventually reach state 1 and stay there. Those
runs recognize scenarios where at some point the door is open and the
light is off. There is an infinite number of those runs: they differ
by the number of times they loop on state 0. But since those runs
reach state 1, it means they visited state 0 only a finite number of
times, so they do not validate the acceptance condition.
There can be multiple accepting states, but it is enough to visit one
infinitely often. For instance the following Büchi automaton accept
all runs in which at all point $a$ is true iff $b$ is true at the next
#+NAME: buchi-example3
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'G(a <-> Xb)' -B -d
#+BEGIN_SRC dot :file concept-buchi3.png :cmdline -Tpng :var txt=buchi-example3 :exports results
* Transitions vs. Edges
:CUSTOM_ID: trans-edge
Since automata are labeled by Boolean formulas instead of letters it
is sometimes useful to think of the formula-labeled *edges* of an
automaton as a way to aggregate several letter-labeled *transitions*.
Whenever the distinction is important, for instance when giving the
size of an automaton, we use the terms *edge* and *transition* to
distinguish whether we are looking at the automaton as a graph, or
whether we are actually considering all possible letters that may
have been aggregated in an edge.
Here is a simple example:
#+NAME: te1
#+BEGIN_SRC sh :results verbatim :exports none
cat >concept-te.hoa <<EOF
HOA: v1
Acceptance: 0 t
Start: 0
States: 2
AP: 2 "a" "b"
State: 0 0 0 1 1
State: 1 1 0 0 0
autfilt --merge concept-te.hoa -d
#+BEGIN_SRC dot :file concept-te1.png :cmdline -Tpng :var txt=te1 :exports results
#+NAME: size
#+BEGIN_SRC sh :exports none
autfilt --merge --stats=$arg concept-te.hoa
The above automaton has call_size(arg="%e")[:results raw] edges and
call_size(arg="%t")[:results raw] transitions.
This is because those formula-labeled edges actually simplify the
following transition structure:
#+NAME: te2
#+BEGIN_SRC sh :results verbatim :exports none
autfilt concept-te.hoa -d
#+BEGIN_SRC dot :file concept-te2.png :cmdline -Tpng :var txt=te2 :exports results
The above is actually a different automaton from the point of view of
Spot: it is an automaton with call_size(arg="%t")[:results raw] edges
and as many transitions.
Spot has some function to merge those "parallel transitions" into
larger edges. Limiting the number of edges helps most of the
algorithms that have to explore automata, since they have less
successors to consider.
The distinction between *edge* and *transition* is something we try
maintain in the various interfaces of Spot. For instance the
[[][=--stats= option]] has =%e= or =%t= to count either edges or
transitions. The method used to add new edge into an automaton is
called =new_edge(...)=, not =new_transition(...)=, because it takes a
[[#bdd][BDD]] (representing a Boolean formula) as label. However that naming
convention is recent in the history of Spot. Spot versions up to
1.2.6 used to call everything /transition/ (and what we now call
/transition/ was sometime called /sub-transition/), and traces of this
history may still be present: do not hesitate to file bug reports if
you uncover some confusing use of these terms.
* Acceptance sets & generalized Büchi acceptance
:CUSTOM_ID: acceptance-set
As a rather straightforward generalization of the Büchi acceptance,
let us consider that instead of one set of accepting states, we might
have multiple sets of states. We call these sets /acceptance sets/.
The /generalized Büchi/ acceptance condition states that a run is
accepting iff it visits at least one state of each acceptance set.
The Büchi convention of representing accepting states using a
double circle is not going to work in the generalized Büchi case. So
instead we label each state with the numbers of each acceptance set it
belongs to.
In the automaton below, there are two acceptance sets denoted with ⓿
and ❶: all states labeled with ⓿ belong to acceptance set 0, and all
states labeled with ❶ belong to set 1. Here each acceptance set
contains a single state.
#+NAME: gen-buchi-example1
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa & GFb' | autfilt -S --sat-minimize -d
#+BEGIN_SRC dot :file concept-gba1.png :cmdline -Tpng :var txt=gen-buchi-example1 :exports results
The accepting runs are only those that visit infinitely often both
states, so that means this automaton accepts all words in which $a$
and $b$ are infinitely often true (not necessarily at the same time).
A state can of course belong to multiple acceptance sets, and an
acceptance set may contain multiple states. For instance the
following automaton has the same language as the previous one (despite
its more complex look).
#+NAME: gen-buchi-example2
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa & GFb' -S -d
#+BEGIN_SRC dot :file concept-gba2.png :cmdline -Tpng :var txt=gen-buchi-example2 :exports results
Speaking of size... Let us note that using a generalized Büchi
acceptance condition makes it possible to build smaller automata than
what we can do with Büchi acceptance. We have seen that the above
language (infinitely often $a$ and infinitely often $b$) can be built
with a 2-state generalized-Büchi automaton, but the smallest
equivalent Büchi automaton has three state:
#+NAME: gen-buchi-example-ba
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa & GFb' -B -d
#+BEGIN_SRC dot :file concept-gba-vs-ba.png :cmdline -Tpng :var txt=gen-buchi-example-ba :exports results
Finally, let us point the obvious fact that a Büchi automaton is a
particular case of generalized-Büchi acceptance with a single
acceptance set. Depending on the context, it might be useful to
represent Büchi automaton using double circles (as above), or numbered
acceptance sets (as below). Spot's output routines have options for
#+NAME: gen-buchi-example-ba2
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa & GFb' -B -d.b
#+BEGIN_SRC dot :file concept-gba-vs-ba2.png :cmdline -Tpng :var txt=gen-buchi-example-ba2 :exports results
* Transition-based, vs. Acceptance-based acceptance
:CUSTOM_ID: trans-acc
So far we have discussed examples of /state-based acceptance/:
acceptance sets are sets of states, runs are accepting if these visit
infinitely often some state in each acceptance set, etc.
When /transition-based acceptance/ is used, acceptance sets are now
sets of /edges/ (or set of /transitions/ if you prefer), and runs are
accepting if the edges they visit satisfy the acceptance condition.
Here is an example of Transition-based Generalized Büchi Automaton
#+NAME: tgba-example1
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GF(a & X(a U b))' -d
#+BEGIN_SRC dot :file concept-tgba1.png :cmdline -Tpng :var txt=tgba-example1 :exports results
This automaton accept all ω-words that infinitely often match the
pattern $a^+;b$ (that is: a positive number of letters where $a$ is
true are followed by one letter where $b$ is true).
Using transition-based acceptance allows for more compact automata.
The typical example is the LTL formula =GFa= (infinitely often $a$)
that can be represented using a one-state transition-based Büchi
#+NAME: tgba-example2
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa' -d
#+BEGIN_SRC dot :file concept-tgba2.png :cmdline -Tpng :var txt=tgba-example2 :exports results
While the same property require a 2-state Büchi automaton using
state-based acceptance:
#+NAME: tgba-example3
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba 'GFa' -B -d
#+BEGIN_SRC dot :file concept-tba-vs-ba.png :cmdline -Tpng :var txt=tgba-example3 :exports results
Internally, instead of representing /acceptance sets/ as actual sets
of edges, Spot labels each edge of the automaton by a bit-vector that
lists the acceptance sets an edge belongs to.
There is a flag inside each automaton that tells Spot if an automaton
uses state-based or transition-based acceptance. However, regardless
of the value of this flag, membership to acceptance sets is always
stored on transitions. In the case of an automaton with state-based
acceptance, the convention is that all transition leaving a state will
carry the acceptance-set membership of that state. Doing so allows us
to interpret an automaton state-based acceptance as if it was an
automaton with transition-based acceptance whenever needed.
* Acceptance condition
:CUSTOM_ID: acceptance-condition
Older versions of Spot (up to 1.2.6), used to support only
Transition-based Generalized Büchi Automata (TGBA). This of course
included support for non-generalized or state-based Büchi.
Today, Spot can work with more general forms of acceptance condition.
An acceptance condition actually consists of two pieces: some
acceptance sets, and a formula that tells how to use these acceptance
Acceptance formulas are positive Boolean formula over atoms of the
form =t=, =f=, =Inf(n)=, or =Fin(n)=, where =n= is a non-negative
integer denoting an acceptance set.
- =t= denotes the true acceptance condition: any run is accepting
- =f= denotes the false acceptance condition: no run is accepting
- =Inf(n)= means that a run is accepting if it visits infinitely
often the acceptance set =n=
- =Fin(n)= means that a run is accepting if it visits finitely
often the acceptance set =n=
The above atoms can be combined using only the operator =&= and =|=
(with obvious semantics), and parentheses for grouping. Note that
there is no negation, but an acceptance condition can be negated
swapping =t= and =f=, =&= and =|=, and =Fin(n)= and =Inf(n)=.
For instance the formula =Inf(0)&Inf(1)= specifies that accepting runs
should visit infinitely often the acceptance 0, and infinitely often
the acceptance set 1. This corresponds the generalized Büchi
acceptance with two sets.
The opposite acceptance condition =Fin(0)|Fin(1)= is known as
/generalized co-Büchi acceptance/ (with two sets). Accepting runs
have to visit finitely often set 0 /or/ finitely often set 1.
A /Rabin acceptance condition/ with 3 pairs corresponds to the
following formula: =(Fin(0)&Inf(1)) | (Fin(2)&Inf(3)) |
The following table gives an overview of how some classical acceptance
condition are encoded. The first column gives a name that is more
human readable (those names are defined in the [[#hoa][HOA]] format and are also
recognized by Spot). The second column give the encoding as a
formula. Everything here is case-sensitive.
#+BEGIN_SRC python :results verbatim raw :exports results
import spot
# org-mode recognize | as a table delemiter even in ~|~ or =|= but the
# documented workaround to use \vert{} does not work in ~\vert{}~ or =\vert{}=.
# So until we have a better solution, let's leave the =...= mode to display
# \vert{} characters.
def line(arg):
return ('| {} | {} |\n'
.format(arg, '={}='.format(spot.acc_code(arg)).replace(' | ','|')
.replace('|','= \\vert{} =')))
return "".join(map(line,
["none", "all", "Buchi", "generalized-Buchi 2",
"generalized-Buchi 3", "co-Buchi",
"generalized-co-Buchi 2", "generalized-co-Buchi 3",
"Rabin 1", "Rabin 2", "Rabin 3", "Streett 1",
"Streett 2", "Streett 3",
"generalized-Rabin 3 1 0 2", "parity min odd 5",
"parity max even 5"]))
| none | =f= |
| all | =t= |
| Buchi | =Inf(0)= |
| generalized-Buchi 2 | =Inf(0)&Inf(1)= |
| generalized-Buchi 3 | =Inf(0)&Inf(1)&Inf(2)= |
| co-Buchi | =Fin(0)= |
| generalized-co-Buchi 2 | =Fin(0)= \vert{} =Fin(1)= |
| generalized-co-Buchi 3 | =Fin(0)= \vert{} =Fin(1)= \vert{} =Fin(2)= |
| Rabin 1 | =Fin(0) & Inf(1)= |
| Rabin 2 | =(Fin(0) & Inf(1))= \vert{} =(Fin(2) & Inf(3))= |
| Rabin 3 | =(Fin(0) & Inf(1))= \vert{} =(Fin(2) & Inf(3))= \vert{} =(Fin(4) & Inf(5))= |
| Streett 1 | =Fin(0)= \vert{} =Inf(1)= |
| Streett 2 | =(Fin(0)= \vert{} =Inf(1)) & (Fin(2)= \vert{} =Inf(3))= |
| Streett 3 | =(Fin(0)= \vert{} =Inf(1)) & (Fin(2)= \vert{} =Inf(3)) & (Fin(4)= \vert{} =Inf(5))= |
| generalized-Rabin 3 1 0 2 | =(Fin(0) & Inf(1))= \vert{} =Fin(2)= \vert{} =(Fin(3) & (Inf(4)&Inf(5)))= |
| parity min odd 5 | =Fin(0) & (Inf(1)= \vert{} =(Fin(2) & (Inf(3)= \vert{} =Fin(4))))= |
| parity max even 5 | =Inf(4)= \vert{} =(Fin(3) & (Inf(2)= \vert{} =(Fin(1) & Inf(0))))= |
* ω-Automaton with generalized acceptance
:CUSTOM_ID: automaton-generalized
Spot's automata support arbitrary acceptance conditions as discussed
above. When displaying automata, it is convenient to display the
acceptance condition as well. For instance here is a Rabin automaton
produced by =ltl2dstar= for the LTL formula =GFa | FGb=, but displayed
by Spot:
#+NAME: twa-example1
#+BEGIN_SRC sh :results verbatim :exports none
ltlfilt -l -f 'GFa | FGb' | ltl2dstar --output-format=hoa - - | autfilt --merge -d.a
#+BEGIN_SRC dot :file concept-twa1.png :cmdline -Tpng :var txt=twa-example1 :exports results
* Never claims
:CUSTOM_ID: neverclaim
Never claims are used by [[][Spin]] to represent Büchi automata; they are
part of the Promela language.
Here are two never claims using different syntaxes to represent a
Büchi automaton for the LTL formula =p0 | GFp1= (that is: $p_0$ or
infinitely often $p_1$). The graphical representation of that
automaton follows.
#+BEGIN_SRC sh :results verbatim :exports results
ltl2tgba -s 'p0 | GFp1' > tmp.$$
ltl2tgba -s6 'p0 | GFp1' | pr -m -t tmp.$$ -
never { /* p0 | GFp1 */ never { /* p0 | GFp1 */
T0_init: T0_init:
if do
:: (p0) -> goto accept_all :: atomic { (p0) -> assert(!(p0))
:: (!(p0)) -> goto accept_S2 :: (!(p0)) -> goto accept_S2
fi; od;
accept_S2: accept_S2:
if do
:: (p1) -> goto accept_S2 :: (p1) -> goto accept_S2
:: (!(p1)) -> goto T0_S3 :: (!(p1)) -> goto T0_S3
fi; od;
T0_S3: T0_S3:
if do
:: (p1) -> goto accept_S2 :: (p1) -> goto accept_S2
:: (!(p1)) -> goto T0_S3 :: (!(p1)) -> goto T0_S3
fi; od;
accept_all: accept_all:
skip skip
} }
#+NAME: never-ex1
#+BEGIN_SRC sh :results verbatim :exports none
ltl2tgba -Bd 'p0 | GFp1'
#+BEGIN_SRC dot :file concept-never1.png :cmdline -Tpng :var txt=never-ex1 :exports results
The two different types of never claims differ only in a few syntactic
elements: =do..od= instead of, =assert= instead of =goto
accept_all=, etc. Older Spin releases used to output the first one, while
newer Spin releases (starting with Spin 6.2.4) use the second syntax
as they help Spin to produce more precise counterexamples.
Spot can read and write never claims in both syntaxes, but it cannot
parse never claim that use other features (such as variables) of the
Promela language.
* LBTT's format
:CUSTOM_ID: lbtt
This format was originally introduced by [[][LBT]], a tool for translating
LTL to (state-based) generalized Büchi automata, and then used by
[[][LBTT]], a tool for testing LTL-to-Büchi translators.
For instance the Büchi automaton we used as an example for never