Professional Documents
Culture Documents
Theory of Computation
1/1
Theory of Computation
2/1
Theory of Computation
Dr. Sarmad Abbasi
Theory of Computation
3/1
Logical Theories
x1 x2 R1 (x1 , x2 ) R2 (x1 , x3 )
2
Theory of Computation
4/1
Logical Theories
x1 x2 R1 (x1 , x2 ) R2 (x2 , x1 )
2
xR1 (x, x)
This defines the syntax.
Theory of Computation
5/1
Logical Theories
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
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.
Theory of Computation
8/1
Logical Theories
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.
Theory of Computation
10 / 1
Logical Theories
Let us look at one:
= y x[R1 (x, x, y )]
1
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.
Theory of Computation
12 / 1
Logical Theories
Theory of Computation
13 / 1
Logical Theories
Theory of Computation
14 / 1
Logical Theories
y x[x + x = y ]
Theory of Computation
15 / 1
Logical Theories
y zx[(x + x = y ) (y + x = z)]
xy z[(z + x = z + y ) (y + x = z + z])]
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?
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
Theory of Computation
18 / 1
Logical Theories
Theory of Computation
19 / 1
Logical Theories
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.
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
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
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
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
Theory of Computation
25 / 1
Logical Theories
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
Theory of Computation
27 / 1
Logical Theories
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?
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
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.
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
.
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 .
Theory of Computation
35 / 1
Logical Theories
Theory of Computation
36 / 1