parixit prasad december 4, 2013 parixit prasad | csa - iisc 1 deciding presburger arithmetic using...
TRANSCRIPT
Parixit Prasad | CSA - IISC
1
PARIXIT PRASAD
December 4, 2013
Deciding Presburger Arithmetic Using Automata
Department of Computer Science and AutomatonIndian Institute of Science, Bangalore
December 4, 2013
Parixit Prasad | CSA - IISC
2
Structure of presentation
December 4, 2013
Recall Finite Automata Presburger Arithmetic
Sets of Integers recognized by a Finite Automaton
Presburger Formulas to Finite Automata Automata Associated with equalities Automata Associated with inequalities
Closure Properties and Automata for arbitrary formulas
Deciding satisfiability of a formula
Parixit Prasad | CSA - IISC
3
Finite Automata
December 4, 2013
A Finite Automaton is a tuple (Q,∑,δ,q0,F).› Q = Finite set of states› ∑ = Finite set of input symbols› δ (Qx∑xQ)› q0 Q (the start state)› F Q (Finite set of final states)
A run of the automaton on the word ω ∑* is a word ρ Q* , such that:
› ρ[1] = q0 › If ρ[i] = p and ρ[i+1] = q , then (p, ω[i],q) δ
A successful run ρ on ω is when ρ[n+1] F , where n=|ω|
A string is accepted by the automaton when there is a successful run on that string.
Class of languages accepted by finite automaton is closed under union, intersection and complementation.
Parixit Prasad | CSA - IISC
4
Presburger Arithmetic
December 4, 2013
A Basic term in presburger arithmetic consists of first order variable, constants 0 & 1 and sums of basic terms.
› x+x+x+y+1+1 is a basic term which can also be written as 3x+y+2
The Atomic formulas are equalities and inequalities between basic terms.
› x-2y = -2 is an atomic formula with equality.› x-2y ≤ -2 is an atomic formula with inequality.
The Formulas are first-order formulas build on atomic formulas using the connectives Λ(conjunction), V(disjunction), ¬(negation), x (existential quantification), x (universal quantification).
› x, y.(x=2y V x=2y+1) is a formula.› Τ is the empty conjunction (valid formula).› is the empty disjunction (unsatisfiable formula).
Parixit Prasad | CSA - IISC
5
The Free variables of a formula φ are defined as:› FV(φ) = variables which are not quantified in φ› FV(φ1 V φ2) = FV(φ1) U FV(φ2)› FV(x.φ) = FV(φ) \ {x}
The interpretation domain of the formulas is the set of natural
numbers N, with 0, 1, +, =, ≤ having their usual meaning.
A solution of the formula φ is an assignment of x1,x2,…,xn in N which satisfies φ, where FV(φ)={x1,x2,…,xn}
› ( x↦2, y↦1 ) is one solution of x+3 = 4y+1› ( x↦4 ) is one solution of y.(x=2y)
Presburger Arithmetic (Contd.)
December 4, 2013
Parixit Prasad | CSA - IISC
6
Sets of Integers recognized by Finite Automaton
December 4, 2013
Every Natural number can be written as a word in base-k (k≥1)
over the alphabet set {0,1,…,(k-1)}
› 29 in base-2 is written as
Since we want to read the word from LSB to MSB, we write the
word from right to left, with LSB in left and MSB in right.
› 29 in base-2 is written as
Parixit Prasad | CSA - IISC
7
Integers recognized by Finite Automaton(Contd.)
December 4, 2013
There is a mapping from {0,1,…,(k-1)}* to N denoted by ~k which
maps each word in base-k to its corresponding Natural number.
› 101110 maps to 29
n-tuples of natural number can be represented in base-k as a single
word over the alphabet set {0,1,…,(k-1)}n
› {0,1,…,(k-1)}3 set is {0,1,…,(k-1)} x {0,1,…,(k-1)} x {0,1,…,(k-1)}
› (13,29,6) (base-10) can be written in base-2 over the alphabet
set {0,1}3
as:
1 0 1 1 0
1 0 1 1 1
0 1 1 0 0
1 0 1 1 0 0
1 0 1 1 1 0
0 1 1 0 0 0
1 0 1 1 0 0 0
1 0 1 1 1 0 0
0 1 1 0 0 0 0
Parixit Prasad | CSA - IISC
8
Presburger Formula to Finite Automata
December 4, 2013
1. Build automaton for the atomic formulas in the given formula› Automata Associated with equalities› Automata Associated with inequalities
2. Use these automaton to create the automata for the given formula
Parixit Prasad | CSA - IISC
9
Automata associated with equality
December 4, 2013
For every atomic formula
a1x1 + a2x2 + … + anxn = b (where a1, a2,…, an, b Z)
we construct the automaton by repeating the following inference
rule untilno more states or transitions can be added:
where, i {0,1} clearly, {0,1}n
Parixit Prasad | CSA - IISC
10
Automata associated with equality (Contd.)
December 4, 2013
The resulting automata would be (Q, ∑, δ, qb, F)
› Q = {qi’s computed by the inference rule}
› ∑ = {0,1}n
› δ (Qx∑xQ) computed by the reference rule
› qb is the initial state
› F =
Parixit Prasad | CSA - IISC
11
Automata associated with equality (Example)
December 4, 2013
Consider the equation : x-2y = -2
› We have b=-2 , so the initial state q-2Q
Let c=b
Compute the solutions θ=(xθ1, yθ2) of the equation: x-2y =2 c
› The solutions are {(x , y ), (x , y )} for c=-2
Compute the new states for each θ and the transition to them from
c
› For θ=(x , y ), d = = = -1
• add q-1Q
• add (q-2,,q-1)δ
Similarly calculate the state and transition for other θ’s
Repeat for each new state until no more new states can be added.
Parixit Prasad | CSA - IISC
12
Automaton for: x-2y=-2
December 4, 2013
q-2
q-1
q0
00
01
10
11
00
q1
01
10
11
Parixit Prasad | CSA - IISC
13
Getting solutions from the automaton
December 4, 2013
For every successful run of the automaton, we get one solution.
For example, for the successful run ρ = q-2 q-1 q-1 q0 q1 q0
q-2 q-1 q-1 q0 q1 q0
› x = 01101 = 22
› y = 00110 = 12
› This is one solution to the equation: x-2y=-2
Parixit Prasad | CSA - IISC
14
Observations on the automaton
December 4, 2013
For an automaton for: a1x2+a2x2+…+anxn=b
1. The absolute value of the states are bounded by:
max(|b|,
2. Any successful run starting from qc gives a solution to:
a1x2+a2x2+…+anxn=c
Parixit Prasad | CSA - IISC
Automata associated with inequality
December 4, 2013
15
Every inequality can be written in the form of:
a1x1 + a2x2 + … + anxn ≤ b (where a1, a2,…, an, b Z)
we construct the automaton by repeating the following inference
rule untilno more states or transitions can be added:
where, i {0,1} clearly, {0,1}n
we apply this formula for all possible combinations of
Parixit Prasad | CSA - IISC
16
Automata associated with inequality (Contd.)
December 4, 2013
The resulting automata would be (Q, ∑, δ, qb, F)
› Q = {qi’s computed by the inference rule}
› ∑ = {0,1}n
› δ (Qx∑xQ) computed by the reference rule
› qb is the initial state
› F = {qc|c≥0}
Parixit Prasad | CSA - IISC
17
Automata associated with inequality (Example)
December 4, 2013
Consider the equation : x-2y ≤ -2
› We have b=-2 , so the initial state q-2Q
Let c=b
Take θ=(xθ1, yθ2), where θ1, θ2 {0,1}
› θ {(x , y ), (x , y ) , (x , y ) , (x , y )}
Compute the new states for each θ and the transition to them from
c
› For θ=(x , y ), d = = = -1
• add q-1Q
• add (q-2,,q-1)δ
Similarly calculate the state and transition for other θ’s
Repeat for each new state until no more new states can be added.
Parixit Prasad | CSA - IISC
18
Automaton for: x-2y≤-2
December 4, 2013
q-2
q-1
q0
00
01
,10
,11
00
q1
01
,10
,
10
00
01
,11
00
,11011
0
Parixit Prasad | CSA - IISC
19
Getting solutions from the automaton
December 4, 2013
For every successful run of the automaton, we get one solution.
For example, for the successful run ρ = q-2 q-1 q-1 q0 q1 q0
q-2 q-1 q-1 q0 q1 q0
› x = 11001 = 19
› y = 10110 = 13
› This is one solution to the equation: x-2y≤-2
Parixit Prasad | CSA - IISC
20
Closure Properties and automata for arbitrary formula
December 4, 2013
Let Aφ(x1,x2,…,xn) be an automaton over alphabet {0,1}n which
accepts the solutions of the formula φ.
› Then FV(φ) {x1,x2,…,xn}
› xi accepting or not accepting a word in the automaton will not
depend on the ith track.
Exercise:
How to compute Aφ(x1,x2,…,xn,y)? Given Aφ(x1,x2,…,xn) and y .
Parixit Prasad | CSA - IISC
21
Automata for arbitrary formulas (Contd.)
December 4, 2013
Given 2 Automata A() and A()
› A can be computed by the intersection of the two given
automaton
› A can be computed by the union of the two given automaton
› We have to make sure that contains FV(φ1) U FV(φ2), which can
be done easily.
Given Automata Aφcan construct A¬φ by taking complement of Aφ
A can be computed from Aφ by projection, i.e. in Aφ simply forgetting
about the track corresponding to x in the transition labels.
Since is logically equivalent to ¬, we can easily compute A Aφ
Parixit Prasad | CSA - IISC
22
An example of Projection
December 4, 2013
Automaton for: x-2y = -2)
q-2
q-1
q0
0¿
0¿
1¿
1¿
0¿
q1
0¿
1¿
1¿
Parixit Prasad | CSA - IISC
23
Deciding satisfiability of a formula
December 4, 2013
We can apply induction on the Presburger formula φ to compute an
automaton φ which accepts the set of solutions of φ.
By computing φ , deciding satisfiability of φ reduces to deciding the
emptiness of the language of φ, which can be done in linear time
w.r.t number of states.
Parixit Prasad | CSA - IISC
24
Thank you
December 4, 2013
Questions…