Theory of Computation
Theory of Computation
Example
Defining language of EVEN
Step 1:
2 is in EVEN.
Step 2:
If x is in EVEN then x+2 and x-2 are also in
EVEN.
Step 3:
No strings except those constructed in above,
are allowed to be in EVEN.
Example
Defining the language factorial
Step 1:
As 0!=1, so 1 is in factorial.
Step 2:
n!=n*(n-1)! is in factorial.
Step 3:
No strings except those constructed in above,
are allowed to be in factorial.
Arithmetic Expressions
Suppose we ask ourselves what constitutes a
valid arithmetic expression, or AE for short.
The alphabet for this language is
= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, -, *, /, (, )}
Theory Of Automata
9
Arithmetic Expression AE
Obviously, the following expressions are not valid:
(3 + 5) + 6)
2(/8 + 9)
(3 + (4-)8)
The first contains unbalanced parentheses; the second
contains the forbidden substring /; the third contains the
forbidden substring -).
Are there more rules? The subsequences // and */ are
also forbidden.
Are there still more?
The most suitable way of defining a valid AE is by using
a recursive definition, rather than a long list of
forbidden substrings.
Theory Of Automata
10
Recursive Definition of AE
Rule 1: Any number (positive, negative, or zero) is in
AE.
Theory Of Automata
12
Theorem
An arithmetic expression cannot contain the
character $.
Proof
This character is not part of any number, so it cannot be
introduced into an AE by Rule 1.
If the character string x does not contain the character $,
then neither do the string (x) and -x. So, the character $
cannot be introduced into an AE by Rule 2.
If neither x nor y contains the character $, then neither
do any of the expressions defined in Rule 3.
Therefore, the character $ can never get into an AE.
Theorem 3 & 4
No arithmetic expression can begin or end
with the symbol /.
Proof?
No arithmetic expression can contain the
substring //.
Proof?
Propositional Calculus
Propositional calculus (or sentential calculus) is
a branch of symbolic logic that we shall be
interested in.
The version we define here uses only negation
() and implication (), together with the phrase
variables.
The alphabet for this language is
= {, , (, ), a, b, c, d, }
A valid expression in this language is called
WFF (well-form formula).
Propositional Calculus
The rules for forming WFFs are:
Rule 1: Any single Latin letter is a WFF, for instance a,
b, c, ...
Rule 2: If p is a WFF, then so are (p) and p.
Rule 3: If p and q are WFFs, then so is p q.
Can you show that p ((p p) q) is a WFF?
Can you show that the following are NOT WFFs?
p
p
p) p(
Useful Reading
Third chapter of Daniel I. Cohen book.
18