You are on page 1of 36

Theory of Computation

Dr. Sarmad Abbasi

Dr. Sarmad Abbasi ()

Theory of Computation

1/1

Lecture 13: Overview

Decidability of Logical Theories


Presburger arithmetic
Decidability of Presburger Arithmetic

Dr. Sarmad Abbasi ()

Theory of Computation

2/1

Theory of Computation
Dr. Sarmad Abbasi

Dr. Sarmad Abbasi ()

Theory of Computation

3/1

Logical Theories

We started with an alphabet.


{, , , (, ), , , x, R1 , R2 , . . . , Rk }
We considered formulas with this alphabet. Some examples of formulas
1

x1 x2 R1 (x1 , x2 ) R2 (x1 , x3 )
2

x1 x2 x3 R2 (x1 ) (R3 (x1 , x3 ) R1 (x2 , x2 ))

Dr. Sarmad Abbasi ()

Theory of Computation

4/1

Logical Theories

A sentence is a formula without any free variables:


1

x1 x2 R1 (x1 , x2 ) R2 (x2 , x1 )
2

xR1 (x, x)
This defines the syntax.

Dr. Sarmad Abbasi ()

Theory of Computation

5/1

Logical Theories

To specify a model M. We have to specify


1

U the universe where the variables will take values.

P1 , . . . , Pk are relation assigned to symbols R1 , . . . , Rk .

Dr. Sarmad Abbasi ()

Theory of Computation

6/1

Logical Theories

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
1

R1 is assigned a binary relation P1 .

R2 is assigned a unary relation P2 .

R3 is assigned a 5-ary relation P3 .

Dr. Sarmad Abbasi ()

Theory of Computation

7/1

Logical Theories

The formula
x1 x2 (R1 (x1 , x2 ) R2 (x4 )) (R3 (x2 , x1 , x3 , x4 , x5 )
is in the language. Since, all relations have the right airty but
x1 x2 (R1 (x1 ) R2 (x4 )) (R3 (x2 , x1 )
is not since the airty of two relations is wrong.

Dr. Sarmad Abbasi ()

Theory of Computation

8/1

Logical Theories

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/1

Logical Theories

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

10 / 1

Logical Theories
Let us look at one:
= y x[R1 (x, x, y )]
1

M1 was the model with N as the universe. R1 was assigned PLUS.


The sentence can be rewritten as
= y x[x + x = y ]
and it is not true.

M2 was the model with R as the universe. R1 was again assigned


PLUS. The sentence can be rewritten as
= y x[x + x = y ]
and it is true.
Dr. Sarmad Abbasi ()

Theory of Computation

11 / 1

Logical Theories

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

12 / 1

Logical Theories

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

13 / 1

Logical Theories

Let us start with a simpler theory. This theory is called Presburger


Arithmetic.
1

The universe is the natural numbers N .

Two relations + and = with their usual meaning.

So only multiplication is missing in Presburger Arithmetic.

Dr. Sarmad Abbasi ()

Theory of Computation

14 / 1

Logical Theories

Let us look at some sentences:


1

y x[x + x = y ]

xy 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

15 / 1

Logical Theories

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:
1

y zx[(x + x = y ) (y + x = z)]

xy 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

16 / 1

Logical Theories

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

17 / 1

Logical Theories

Let us be more clear. How will the input be given to the DFA. Let us define

0
0
0
1
1
1
1
0

0 , 0
1 , 1 , 0 , 0 , 1 , 1
3 =

0
1
0
1
0
1
0
1

Dr. Sarmad Abbasi ()

Theory of Computation

18 / 1

Logical Theories

Now, we can give input to the DFA. Suppose x = 5, y = 3, z = 6 then the


input to the DFA would be

1
0
1
0 1 1
1
1
0
1

The top row 101 is x in binary.

The second row 011 is y in binary.

The third row 110 is z in binary.

Dr. Sarmad Abbasi ()

Theory of Computation

19 / 1

Logical Theories

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

20 / 1

Logical Theories

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:
010100
001111
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

21 / 1

Logical Theories
c =0
0 0 1 0 1 0
1 1 1 1 0 0
1
c =0
0 0 1 0 1 0
1 1 1 1 0 0
1 1
c =0
0 0 1 0 1 0
1 1 1 1 0 0
1 1 0

Dr. Sarmad Abbasi ()

Theory of Computation

22 / 1

Logical Theories
c =1
0 0 1 0 1 0
1 1 1 1 0 0
1 1 0 0
c =1
0 0 1 0 1 0
1 1 1 1 0 0
1 1 0 0 0
c =1
0 0 1 0 1 0
1 1 1 1 0 0
1 1 0 0 0 1

Dr. Sarmad Abbasi ()

Theory of Computation

23 / 1

Logical Theories
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.
q0 , q1 and qr . q0 is the accept state. Here are the transitions. When the
machine is in q0 the carry is 0. When it is in q1 the carry is 1.
1

0
(q0 , 0 ) = q0
0
2

0
(q0 , 0 ) = qr
1

Dr. Sarmad Abbasi ()

Theory of Computation

24 / 1

Logical Theories
1

0
(q0 , 1 ) = qr
0
2

0
(q0 , 1 ) = q0
1
3

1
(q0 , 1 ) = q1
0

Dr. Sarmad Abbasi ()

Theory of Computation

25 / 1

Logical Theories

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 / 1

Logical Theories
What about other equations in Presburger Arithmetic. Let us think about
x +y =z +z +t
We can use the same trick.
Let

0


0
,
4 =

,
1

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 / 1

Logical Theories

Given a atomic formula F (in Presburger Arithmetic) in i variables


x1 , . . . , xi
variables we define
i
to be an alphabet with 2i characters. Each string S i defines i
numbers a1 , . . . , ai . We can make a DFA D such that
D accepts S if and only if a1 , . . . , ai satisfy the equation F .

Dr. Sarmad Abbasi ()

Theory of Computation

28 / 1

Logical Theories

x 1 + x 2 + x2 + x2 = x3 + x3 + x4 + x5 .

x 1 + x2 + x3 + x5 = x4 + x4 + x4

We can make DFA D1 such which accepts strings over 5 in the first case
and another DFA D2 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 / 1

Logical Theories
What about non atomic formulas?

(x1 + x2 + x2 + x2 = x3 + x3 + x4 + x5 ) (x1 + x2 + x3 + x5 = x4 + x4 + x4 )

(x1 + x2 + x2 + x2 = x3 + x3 + x4 + x5 ) (x1 + x2 + x3 + x5 = x4 + x4 + x4 )

(x1 + x2 + x2 + x2 = x3 + x3 + x4 + x5 ) (x1 + x2 + x3 + x5 = x4 + x4 + x4 )
In the first case we can make a DFA that accepts all the strings accepted
by D1 or D2 . Regular languages are closed under union, intersection and
complementarily.
Dr. Sarmad Abbasi ()

Theory of Computation

30 / 1

Logical Theories

Given quantifier free formula f (in Presburger Arithmetic) in i variables


x1 , . . . , xi
variables we define
i
to be an alphabet with 2i characters. Each string S i defines i
numbers a1 , . . . , ai . We can make a DFA D such that
D accepts S if and only if a1 , . . . , ai satisfy F .

Dr. Sarmad Abbasi ()

Theory of Computation

31 / 1

Logical Theories
What about formulas with quantifiers lets look at one of them:
x3 [x1 + x2 + x2 = x3 ]
.
This formula has two free variables
x 1 , x2
So lets work with 2 and 3 . We can make a DFA D that accepts strings
S 3 such that S represents x1 , x2 and x3 which satisfy
x1 + x2 + x2 = x3
.
We would like a DFA D 0 that accepts strings S 0 2 such that S 0
represent x1 , x2 and satisfy
x3 [x1 + x2 + x2 = x3 ]
.
Dr. Sarmad Abbasi ()

Theory of Computation

32 / 1

Logical Theories

It is much easier to make an NFA given the DFA D. The NFA N simply
guesses the value of x3 as it goes along moving to the right. Thus in each
move it makes two non-deterministic moves. One pretending the current
bit of x3 is 0 and the other pretending that it is 1. We can then convert
this NFA N to a DFA using a standard algorithm.

Dr. Sarmad Abbasi ()

Theory of Computation

33 / 1

Logical Theories

We can deal with quantifiers like this one by one. Let say we have a
formula
= xi
First we make an DFA D that accepts those over i that represent
x1 , . . . , xi and satisfy . Then we make an NFA that uses D and guesses
the value of each bit of xi as it goes along. We convert this D to D 0 which
now accepts strings over
i1
.

Dr. Sarmad Abbasi ()

Theory of Computation

34 / 1

Logical Theories

How to handle
= xi
This is easy since
xi =
First we make an DFA D that accepts those over i that represent
x1 , . . . , xi 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 / 1

Logical Theories

This way if we have a sentence


Q 1 x1 Q2 x 2 x i
We can make a DFA D that will accept the empty string over 0 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 / 1