Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation /
Lecture 3: Overview Decidability of Logical Theories Presburger arithmetic Decidability of Presburger Arithmetic Dr. Sarmad Abbasi () Theory of Computation 2 /
Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation 3 /
We started with an alphabet. {,,, (, ),,, x, R, R 2,..., R k } We considered formulas with this alphabet. Some examples of formulas 2 x x 2 R (x, x 2 ) R 2 (x, x 3 ) x x 2 x 3 R 2 (x ) (R 3 (x, x 3 ) R (x 2, x 2 )) Dr. Sarmad Abbasi () Theory of Computation 4 /
A sentence is a formula without any free variables: 2 This defines the syntax. x x 2 R (x, x 2 ) R 2 (x 2, x ) xr (x, x) Dr. Sarmad Abbasi () Theory of Computation 5 /
To specify a model M. We have to specify U the universe where the variables will take values. 2 P,..., P k are relation assigned to symbols R,..., R k. Dr. Sarmad Abbasi () Theory of Computation 6 /
The language of a model M is the set of all formulas which use the relation symbols with correct airy Suppose in the model M R is assigned a binary relation P. 2 R 2 is assigned a unary relation P 2. 3 R 3 is assigned a 5-ary relation P 3. Dr. Sarmad Abbasi () Theory of Computation 7 /
The formula x x 2 (R (x, x 2 ) R 2 (x 4 )) (R 3 (x 2, x, x 3, x 4, x 5 ) is in the language. Since, all relations have the right airty but x x 2 (R (x ) R 2 (x 4 )) (R 3 (x 2, x ) is not since the airty of two relations is wrong. Dr. Sarmad Abbasi () Theory of Computation 8 /
If M is a model. We let TH(M) denote the theory of M. It is by definition the set of all sentences that are true sentences in the language of that M. A central point of investigation is to find out which theories are decidable and which ones are not. Dr. Sarmad Abbasi () Theory of Computation 9 /
Note that when we are talking about a model in which relations have some usual meaning then we shift to infix notation. We also saw examples of sentences that are true in one model and false in another model. Dr. Sarmad Abbasi () Theory of Computation /
Let us look at one: φ = y x[r (x, x, y)] M was the model with N as the universe. R was assigned PLUS. The sentence can be rewritten as and it is not true. φ = y x[x + x = y] 2 M 2 was the model with R as the universe. R was again assigned PLUS. The sentence can be rewritten as and it is true. φ = y x[x + x = y] Dr. Sarmad Abbasi () Theory of Computation /
Given a Model M we would like to know which sentences are true and which ones are not true. What we want is a decision procedure or an algorithm which will take a sentence and tell us if the sentence is true or not. Dr. Sarmad Abbasi () Theory of Computation 2 /
One of the most interesting model is number theory where M with relation + and, =, with their usual meaning. This theory is undecidable. This is a major theorem by Alonzo Church building on the work of Godel. Dr. Sarmad Abbasi () Theory of Computation 3 /
Let us start with a simpler theory. This theory is called Presburger Arithmetic. The universe is the natural numbers N. 2 Two relations + and = with their usual meaning. So only multiplication is missing in Presburger Arithmetic. Dr. Sarmad Abbasi () Theory of Computation 4 /
Let us look at some sentences: y x[x + x = y] 2 x y z[(x + y = z) ((x + x + y = z) (x + y = z + z + z))] Note that it is possible to write 5x as x + x + x + x + x. However, we cannot write xy or x 2. So in this theory the variables are only multiplied by constants. We cannot use higher powers either. Dr. Sarmad Abbasi () Theory of Computation 5 /
We want to prove that this theory is decidable. So, we want to design an algorithm (or a TM) with will take as input a sentence and decide if it is true or not. How does the input look like: y z x[(x + x = y) (y + x = z)] 2 x y z[(z + x = z + y) (y + x = z + z])] How will the algorithm decide if a sentence is true. Dr. Sarmad Abbasi () Theory of Computation 6 /
Lets start with something simpler. Let us look at the simple atomic formula x + y = z Can we design a DFA that accepts x, y, z if and only if they satisfy this equation? Dr. Sarmad Abbasi () Theory of Computation 7 /
Let us be more clear. How will the input be given to the DFA. Let us define Σ 3 =,,,,,, Dr. Sarmad Abbasi () Theory of Computation 8 /
Now, we can give input to the DFA. Suppose x = 5, y = 3, z = 6 then the input to the DFA would be The top row is x in binary. 2 The second row is y in binary. 3 The third row is z in binary. Dr. Sarmad Abbasi () Theory of Computation 9 /
Can we design a DFA where the input alphabet is Σ 3 and it accepts a string I Σ 3 such that the top row of the string when added to the second row of the string gives us the last row of the string? Dr. Sarmad Abbasi () Theory of Computation 2 /
The answer is yes. But it is easier if the machine is given the strings in reverse. Lets see how do we add in binary: The way we add is we remember the carry and compute the next digit and keep moving left. If the numbers were given to us in reverse we will remember the carry and keep moving right. So, if these numbers were given to us in reverse. Dr. Sarmad Abbasi () Theory of Computation 2 /
c = c = c = Dr. Sarmad Abbasi () Theory of Computation 22 /
c = c = c = Dr. Sarmad Abbasi () Theory of Computation 23 /
If the answer were given to us. We could check it as we go along. Actually this DFA is very very simple. Let us look at it. It has only two state and a trap state. q, q and q r. q is the accept state. Here are the transitions. When the machine is in q the carry is. When it is in q the carry is. 2 δ(q, δ(q, ) = q ) = q r Dr. Sarmad Abbasi () Theory of Computation 24 /
2 3 δ(q, δ(q, δ(q, ) = q r ) = q ) = q Dr. Sarmad Abbasi () Theory of Computation 25 /
So we can make a DFA which accepts all strings I Σ 3 such that The top row of I read revered in binary + Second row of I read reversed in binary = Last row of I read reverse in binary Thus if I represents three numbers x, y and z then the DFA accepts if and only if x + y = z. Dr. Sarmad Abbasi () Theory of Computation 26 /
What about other equations in Presburger Arithmetic. Let us think about We can use the same trick. Let Σ 4 = x + y = z + z + t,, Each string I Σ 4 represents four numbers x, y, z and t written in reverse binary. We can make a DFA D such that D accepts I if and only if. x + y = z + z + t Dr. Sarmad Abbasi () Theory of Computation 27 /
Given a atomic formula F (in Presburger Arithmetic) in i variables variables we define x,..., x i to be an alphabet with 2 i characters. Each string S Σ i defines i numbers a,..., a i. We can make a DFA D such that D accepts S if and only if a,..., a i satisfy the equation F. Σ i Dr. Sarmad Abbasi () Theory of Computation 28 /
x + x 2 + x 2 + x 2 = x 3 + x 3 + x 4 + x 5. 2 x + x 2 + x 3 + x 5 = x 4 + x 4 + x 4 We can make DFA D such which accepts strings over Σ 5 in the first case and another DFA D 2 which accepts strings over Σ 5. So, in some sense DFAs can capture atomic formulas of Presburger Arithmetic. What about non atomic formulas? Dr. Sarmad Abbasi () Theory of Computation 29 /
What about non atomic formulas? (x + x 2 + x 2 + x 2 = x 3 + x 3 + x 4 + x 5 ) (x + x 2 + x 3 + x 5 = x 4 + x 4 + x 4 ) (x + x 2 + x 2 + x 2 = x 3 + x 3 + x 4 + x 5 ) (x + x 2 + x 3 + x 5 = x 4 + x 4 + x 4 ) (x + x 2 + x 2 + x 2 = x 3 + x 3 + x 4 + x 5 ) (x + x 2 + x 3 + x 5 = x 4 + x 4 + x 4 ) In the first case we can make a DFA that accepts all the strings accepted by D or D 2. Regular languages are closed under union, intersection and complementarily. Dr. Sarmad Abbasi () Theory of Computation 3 /
Given quantifier free formula f (in Presburger Arithmetic) in i variables variables we define x,..., x i to be an alphabet with 2 i characters. Each string S Σ i defines i numbers a,..., a i. We can make a DFA D such that D accepts S if and only if a,..., a i satisfy F. Σ i Dr. Sarmad Abbasi () Theory of Computation 3 /
What about formulas with quantifiers lets look at one of them:. This formula has two free variables x 3 [x + x 2 + x 2 = x 3 ] x, x 2 So lets work with Σ 2 and Σ 3. We can make a DFA D that accepts strings S Σ 3 such that S represents x, x 2 and x 3 which satisfy x + x 2 + x 2 = x 3. We would like a DFA D that accepts strings S Σ 2 such that S represent x, x 2 and satisfy x 3 [x + x 2 + x 2 = x 3 ]. Dr. Sarmad Abbasi () Theory of Computation 32 /
It is much easier to make an NFA given the DFA D. The NFA N simply guesses the value of x 3 as it goes along moving to the right. Thus in each move it makes two non-deterministic moves. One pretending the current bit of x 3 is and the other pretending that it is. We can then convert this NFA N to a DFA using a standard algorithm. Dr. Sarmad Abbasi () Theory of Computation 33 /
We can deal with quantifiers like this one by one. Let say we have a formula φ = x i ψ First we make an DFA D that accepts those over Σ i that represent x,..., x i and satisfy ψ. Then we make an NFA that uses D and guesses the value of each bit of x i as it goes along. We convert this D to D which now accepts strings over Σ i. Dr. Sarmad Abbasi () Theory of Computation 34 /
How to handle This is easy since φ = x i ψ x i ψ = ψ First we make an DFA D that accepts those over Σ i that represent x,..., x i and satisfy ψ. Thus we can use the fact that regular languages are closed under complementarily to make a DFA D that accepts φ. We also use the technique for handling. Dr. Sarmad Abbasi () Theory of Computation 35 /
This way if we have a sentence Q x Q 2 x 2 x i φ We can make a DFA D that will accept the empty string over Σ if and only if the formula is true. In the end we run D on the empty string to see if accepts ɛ. If it does then the formula is true. Otherwise it is false. Dr. Sarmad Abbasi () Theory of Computation 36 /