240 likes | 385 Views
Deciding Presburger Arithmetic Using Automata. Parixit Prasad. Department of Computer Science and Automaton Indian Institute of Science, Bangalore December 4, 2013. Structure of presentation. Recall Finite Automata Presburger Arithmetic Sets of Integers recognized by a F inite Automaton
E N D
Deciding Presburger Arithmetic Using Automata Parixit Prasad Department of Computer Science and Automaton Indian Institute of Science, Bangalore December 4, 2013 Parixit Prasad | CSA - IISC
Structure of presentation • 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
Finite Automata • A Finite Automaton is a tuple (Q,∑,δ,q0,F). • Q = Finite set of states • ∑ = Finite set of input symbols • δ(Qx∑xQ) • q0Q (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 isclosed under union, intersection and complementation. Parixit Prasad | CSA - IISC
Presburger Arithmetic • 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
Presburger Arithmetic (Contd.) • The Free variables of a formula φ are defined as: • FV(φ) = variables which are not quantified in φ • FV(φ1Vφ2) = FV(φ1) U FV(φ2) • FV(x.φ) = FV(φ) \ {x} • The interpretationdomain 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,…,xnin Nwhich 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) Parixit Prasad | CSA - IISC
Sets of Integers recognized by Finite Automaton • 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
Integers recognized by Finite Automaton(Contd.) • 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 setis {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: Parixit Prasad | CSA - IISC
Build automaton for the atomic formulas in the given formula Automata Associated with equalities Automata Associated with inequalities Use these automaton to create the automata for the given formula Presburger Formula to Finite Automata Parixit Prasad | CSA - IISC
Automata associated with equality • For every atomic formula • a1x1 + a2x2 + … + anxn = b (where a1, a2,…, an, b Z) • we construct the automaton by repeating the following inference rule until • no more states or transitions can be added: • where, i {0,1} • clearly, {0,1}n Parixit Prasad | CSA - IISC
Automata associated with equality (Contd.) • 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
Automata associated with equality (Example) • 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
Automaton for: x-2y=-2 q-1 q1 q-2 q0 Parixit Prasad | CSA - IISC
Getting solutions from the automaton • For every successfulrun of the automaton, we get one solution. • For example, for the successful run ρ = q-2 q-1q-1 q0 q1 q0 • q-2q-1q-1q0q1q0 • x = 01101 = 22 • y = 00110 = 12 • This is one solution to the equation: x-2y=-2 Parixit Prasad | CSA - IISC
Observations on the automaton • For an automaton for: a1x2+a2x2+…+anxn=b • The absolute value of the states are bounded by: • max(|b|, • Any successful run starting from qc gives a solution to: • a1x2+a2x2+…+anxn=c Parixit Prasad | CSA - IISC
Automata associated with inequality • 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 until • no 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
Automata associated with inequality (Contd.) • 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
Automata associated with inequality (Example) • 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
Automaton for: x-2y≤-2 q-1 , q-2 q1 q0 Parixit Prasad | CSA - IISC
Getting solutions from the automaton • For every successfulrun of the automaton, we get one solution. • For example, for the successful run ρ = q-2 q-1q-1 q0 q1 q0 • q-2q-1q-1q0q1q0 • x = 11001 = 19 • y = 10110 = 13 • This is one solution to the equation: x-2y≤-2 Parixit Prasad | CSA - IISC
Closure Properties and automata for arbitrary formula • Let Aφ(x1,x2,…,xn) be an automaton over alphabet {0,1}nwhich accepts the solutions of the formula φ. • Then FV(φ) {x1,x2,…,xn} • xiaccepting 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
Automata for arbitrary formulas (Contd.) • Given 2 Automata A() and A() • Acan be computed by the intersection of the two given automaton • Acan be computed by the unionof 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φ • Acan 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 AAφ Parixit Prasad | CSA - IISC
An example of Projection • Automaton for: x-2y = -2) q-1 q1 q-2 q0 Parixit Prasad | CSA - IISC
Deciding satisfiability of a formula • We can apply induction on the Presburger formula φ to compute an automaton φ which accepts the set of solutions of φ. • By computing φ, deciding satisfiabilityof φ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
Thank you Questions… Parixit Prasad | CSA - IISC