Published in ICDT 2017 and available on the Dagstuhl repository:

On the automated verification of web applications with embedded SQL.
Shachar Itzhaky, Tomer Kotek, Noam Rinetzky, Mooly Sagiv, Orr Tamir, Helmut Veith, Florian Zuleger.
International Conference on Database Theory

FO²-solver is a new finite satisfiability solver for FO², the two-variable fragment of first-order logic. FO²-solver receives as input a sentence in FO² and answers whether the sentence is satisfiable by a structure with a finite universe.

The basic principle of FO²-solver uses the bounded model property of FO². The solver computes an upper bound on the universe size of the smallest structure satisfying the input sentence, if any structure which satisfies the sentence exists. Then, the solver uses a SAT solver to search for a model up to the upper bound size. If such a model is found, the sentence is satisfiable. If no such model is found, the sentence is unsatisfiable. The algorithm that the solver uses is sound and complete. Practically, of course, the solver may timeout or run out of space. The solver employs some strategies to lower the upper bound on the universe size and improve performance. For more details, see Section 4 of arXiv:1610.02101. FO²-solver was implemented by Tomer Kotek, based on some basic infrastructure from Shachar Itzhaky‘s EPR-based Verification tool.

The logic FO²

FO² contains all the first-order logic sentences which use only two-variables: x and y. Examples of FO² sentences are:

Φ0 = (∀ x U(x)) ∧ (∃ x ¬ U(x))
Φ1 = (∀ x ∃ y B1(x,y)) → (∃ y ∀ x B2(x,y))

Note that quantification over the same variable can be nested:

Φ2 = ∀ x ∃ y (U(x) → ∃ x B(x,y))

The sentences may use unary relation symbols (such U above) and binary relation symbols (such as B, B1, and B2 above). The sentences may not use function symbols. The equality symbol = is in the language. No other special symbols are allowed (e.g., one cannot assume to have the smaller than < relation on the universe elements). Relation symbols with arity larger than 2 cannot be used.

Additionally, constant symbols may be used. For example:

Φ3 = ∀ x ∀ y (¬(x=c) → B(c,y))
Φ4 = (c1=c2) ∧ B(c1,c2)

Here, c, c1, and c2 are constant symbols.

Input format: SMT-LIBv2

The input format of FO²-solver is SMT-LIBv2. Here is how an smt2 file given as input to FO²-solver should be constructed.


Every smt2 file should start with:

(declare-sort V 0)

Then, the symbols in the sentence are declared.
A binary relation symbol is declared as follows:

(declare-fun B (V V) Bool)

A unary relation symbol is declared as follows:

(declare-fun U (V) Bool)

A constant symbol is declared as follows:

(declare-const c V)

The equality symbol does not need to be declared.

The assert command

After the declarations are done comes the most important part of the smt2 file. Inside the assert command you may use exists, forall, and, or, =>, not, and atomic formulas.

For instance:

(assert (exists ((x V)) (or (B x x) (exists ((y V)) (=> (B x y) (not (= x y)))))))

The check-sat command

Every smt2 should end with:


The command (get-model) is ignored, but it is allowed to occur here for compatibility.


The smt2 file of Φ0 = (∀ x U(x)) ∧ (∃ x ¬ U(x)):

(declare-sort V 0)
(declare-fun U (V) Bool)
(assert (and (forall ((x V)) (U x)) (exists ((x V)) (not (U x)))))

The smt2 file of Φ1 = (∀ x ∃ y B1(x,y)) → (∃ y ∀ x B2(x,y)):

(declare-sort V 0)
(declare-fun B1 (V V) Bool)
(declare-fun B2 (V V) Bool)
(forall ((x V)) (exists ((y V)) (B1 x y)))
(exists ((y V)) (forall ((x V)) (B2 x y)))))

The smt2 file of Φ2 = ∀ x ∃ y (U(x) → ∃ x B(x,y)):

(declare-sort V 0)
(declare-fun U (V) Bool)
(declare-fun B (V V) Bool)
(assert (forall ((x V)) (exists ((y V))
(=> (U x) (exists ((x V)) (B x y))))))

The smt2 file of Φ3 = ∀ x ∀ y (¬(x=c) → B(c,y)):

(declare-sort V 0)
(declare-const c V)
(declare-fun B (V V) Bool)
(assert (forall ((x V) (y V)) (=> (not (= x c)) (B c y))))

The smt2 file of Φ4 = (c1=c2) ∧ B(c1,c2):

(declare-sort V 0)
(declare-const c1 V)
(declare-const c2 V)
(assert (and (not (= c1 c2)) (B c1 c2)))

Download and installation

System requirements

FO²-solver is designed to work on Linux systems with equipped with Java SE 7.


FO²-solver 0.3d (zip, 40.4MB)


Edit the script to point to a SAT solver installed on your system. Any SAT solver which follows DIMACS input/output requirements is compatible (see SAT Competition 2009 for details). FO²-solver has been tested with Glucose and Lingeling.

Running the tool


The basic command to run the solver is:

$ java -jar FO2solver-wrapper.jar filename.smt2

If the –print-model option is used, then FO²-solver prints a satisfying model to stdout if it exists.

$ java -jar FO2solver-wrapper.jar filename.smt2 --print-model

The –sat-solver-path option overrides the setting of the SAT solver path in


FO²-solver begins by testing that the SAT solver is configured properly. If the SAT solver is configured correctly, the following will be printed:

------ Testing SAT solver ------

If there is any error message between these two lines, then the SAT solver is not configured correctly.

Next, FO²-solver will print an output of the form:

Reading smt2 file
Computing formula in normal form
Max model size 200
Searching for a model of size at most 1:
 Preparing input to SAT solver
 Running SAT solver
Searching for a model of size at most 2:
 Preparing input to SAT solver
 Running SAT solver
Searching for a model of size at most 3:
 Preparing input to SAT solver
 Running SAT solver
Searching for a model of size at most 12:
 Preparing input to SAT solver
 Running SAT solver
SATISFIABLE by a model of size at most 12

If the input sentence is unsatisfiable, then the last line will be


If the –print-model option is used and the input sentence is satisfiable, a model will be printed. For example:

--- Satisfying model ---
The universe is 0,...,11
The true atoms are as follows: (atoms which do not occur are false)

The order of the atoms is arbitrary.
In this case, the satisfying model has universe {0,…,11}. The relations in the model are:

U0 = {5}
U1 = {1, 2, 4}
U2 = {3, 6}
U3 = {0}
A = {2, 3, 4, 5, 6, 7, 9, 10, 11}
B = {(0,5), (1,6), (5,1), (6,0), (7,1), (8,0), (9,1)}


The benchmarks from Section 5 of arXiv:1610.02101 are available.

real time web stats

Latest News

Jens Pagel wins Bill McCune PhD Award

We congratulate Jens Pagel for receiving the 2021 Bill McCune PhD Award in Automated Reasoning! Jens graduated in 2020; his thesis on Decision procedures for separation logic: beyond symbolic heaps (supervised by Florian Zuleger) presents his substantial contributions to the theory of formal verification and automated reasoning, and to verifying heap-manipulating programs in particular.

Continue reading

Full news archive