COMP 335:
NPDA Accept
ContextFree Languages
N. Houari, PhD, P.Eng.
Fall 2015
Reading Chap#7
1
Theorem:
ContextFree
Languages
(Grammars)
COMP 335
Languages
Accepted by
NPDAs
2
Proof  Step 1:
ContextFree
Languages
(Grammars)
Languages
Accepted by
NPDAs
Closure Properties of CFLs
Consider a mapping
s : 2
where and are finite alphabets. Let w ,
where w = a1a2 . . . an, and define
s(w) = s(a1).s(a2). .s(an)
and, for L ,
s(L) =
[
s(w).
wL
Such a mapping s is called a substitution.
1
Example: = cfw_0, 1, = c
Department of Computer Science & Software Engineering
Comp335 Introduction to Theoretical Computer Science
Winter 2017
Assignment 4. Due date: April 13, by 23:59 P.M. EDT
1. (a) Construct a Turing machine for the language
cfw_xay x, y cfw_a, b , x = y.
(a
Problems that computers cannot solve
Evidently, it is important to know that programs do what they are supposed to, IOW,
we would like to make sure that programs are
correct.
It is easy to see that the program
main()
cfw_
printf(hello, world\n);
indeed p
Properties of Regular Languages
Pumping Lemma. Every regular language
satisfies the pumping lemma. If somebody
presents you with fake regular language, use
the pumping lemma to show a contradiction.
Closure properties. Building automata from
components
CONCORDIA UNIVERSITY
Dept. of Computer Science and Software Engineering
COMP 335 Introduction to Theoretical Computer Science
Fall 2016
Assignment 3
Electronic Submission is due on Thursday November 17th at 23:59
1. [20 points] Find contextfree grammars
This is a theoretical course, which studies
Introduction to
theory of computation.
Theoretical Computer Science
It discusses formal languages, automata, and
computability. It introduces abstract models of
COMP 335
computation and computers.
Why theory,
Equivalence and Minimization of Automata
Let A = (Q, , , q0, F ) be a DFA, and cfw_p, q Q.
We define
p q w : (p, w) F iff (q, w) F
If p q we say that p and q are equivalent
If p 6 q we say that p and q are distinguishable
IOW (in other words) p and q ar
From regexs to NFAs
Theorem 3.7: For every regex R we can construct and NFA A, s.t. L(A) = L(R).
Proof: By structural induction:
Basis: Automata for , , and a.
(a)
(b)
a
(c)
1
Induction: Automata for R + S, RS, and R
R
S
(a)
R
S
(b)
R
(c)
2
Example: We
Department of Computer Science & Software Engineering
Comp335 Introduction to Theoretical Computer Science
Winter 2017
Assignment 1. Solutions.
1. Construct a DFA for each of the following languages
(a) All and only those strings over cfw_a, b, c whose sy
COMP 335:
Modeling Computation Part I Conclusion
N. Houari, PhD, P.Eng.
Fall 2015
Wrap up part I
1
Introduction
Computers can perform many tasks.
Given a task, two questions arise.
1. Can it be carried out using a computer?
once we know that this first qu
COMP367 / MAST332
Techniques in Symbolic Computation
Lecture 3 Notes:
Congruences (Ch. 5):
Congruence Modulo m (Ch. 5A)
Definition: two integers a and b are said to be congruent modulo m ,
if m divides
, or equivalently, if
, with some
.
Note that
0 (mo
Undecidability
We want to prove undecidable Lu which is the
language of pairs (M, w) such that:
1. M is a TM (encoded in binary) with input
alphabet cfw_0, 1.
2. w cfw_0, 1.
3. M accepts w.
1
The landscape of languages (problems)
Ld .
Lu .
RE Recursive
bu
Equivalence of PDAs and CFGs
A language is
generated by a CFG
if and only if it is
accepted by a PDA by empty stack
if and only if it is
accepted by a PDA by final state
Grammar
PDA by
empty stack
PDA by
final state
We already know how to go between null
Ambiguity in Grammars and Languages
In the grammar
1.
2.
3.
4.
E
E
E
E
I
E+E
EE
(E)
the sentential form E + E E has two derivations:
E E+E E+EE
and
E EE E+EE
This gives us two parse trees:
E
E
E
+
E
E
*
(a)
E
E
E
*
+
E
E
(b)
1
The mere existence of sever
Properties of CFLs
Simplification of CFGs. This makes life easier, since we can claim that if a language is CF,
then it has a grammar of a special form.
Pumping Lemma for CFLs. Similar to the
regular case.
Closure properties. Some, but not all, of the
Concordia University
Dept. of Computer Science and Software Engineering
COMP 335 Introduction to Theoretical Computer Science
http:/users.encs.concordia.ca/~c335_2
Fall 2016
Instructors:
Sections:
Lectures:
Office Hours:
Phones:
Emails:
Web:
N. Shiri
G
TJ
Turing Machines
01/25/17
COMP 335
1
The Language Hierarchy
ww ?
n n n
a b c ?
ContextFree Languages
n n
R
a b
ww
Regular Languages
a*
a *b *
COMP 335
2
Languages accepted by
Turing Machines
ww
n n n
a b c
ContextFree Languages
n n
R
a b
ww
Regular Langu
Standard Representations
of Regular Languages
Regular Languages
DFAs
NFAs
01/25/17
Regular
Grammars
Regular
Expressions
COMP 335
1
When we say: We are given
a regular language
L
it means that :L is in a standard
representation
COMP 335
2
Elementary Questi
 Closure Properties of Regular
Languages
 Regular Expressions
01/25/17
COMP 335
1
NFA with Single Final State
COMP 335
2
Given any NFA, we can always convert
it into an equivalent NFA which has only
ONE final state (how?)
COMP 335
3
Example
a
NFA
b
a
b
More Applications
of
The Pumping Lemma
01/25/17
COMP 335
1
The Pumping Lemma:
For infinite contextfree languageL
there exists an integer m
for any string
w L,
such that
 w m
we can write
w uvxyz
with lengths
 vxy m and  vy 1
and it must be:
i i
uv
ContextFree Grammars
(CFGs)
01/25/17
COMP 335
1
Example
A contextfree grammarG :
S aSb
S
A derivation:
S aSb aaSbb aabb
COMP 335
2
A contextfree grammarG :
S aSb
S
Another derivation:
S aSb aaSbb aaaSbbb aaabbb
COMP 335
3
S aSb
S
n n
L(G ) cfw_a b : n
COMP 335: Introduction to
Theoretical Computer
Science
Fall 2016
http:/users.encs.concordia.ca/~c335_2/
01/25/17
(Original slides:
Konstantin
Busch)
COMP
335
1
This is a theoretical course in which we study
abstract models of computation and computers.
Wh
Linear Bounded Automata LBAs
and the Halting Problem
Winter 2011
COMP 335
1
Linear Bounded Automata (LBAs)
are the same as Turing Machines
with the following difference:
The space on the tape for the input
string is the only space allowed to
use
COMP 335
CONCORDIA UNIVERSITY
COMP 335
DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE
ENGINEERING
Theoretical Computer Science
Summer 2017
Assignment 2
Show all the steps of your solution for full mark.
1. Find a regular expression for the following languages over =
CONCORDIA UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING
COMP 335
Theoretical Computer Science
Summer 2017
Assignment 4
Show all the steps of your solution for full mark.

1. Construct Turing machines (show a diagram) that accept the
CONCORDIA UNIVERSITY
COMP 335
DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE
ENGINEERING
Theoretical Computer Science
Assignment 3
Show all the steps of your solution for full mark.
1. Convert the following grammers into Chomsky normal form
a) S ABb  a
A aa
COMP 335 Tutorial 2
May 10, 2017
Question 1
Give DFAs for the languages
(a) L = cfw_ab5 wb2 : w cfw_a, b
(b) L = cfw_abn am : n 2, m 3
(c) L = cfw_w1 abw2 : w1 cfw_a, b , w2 cfw_a, b
(d) L = cfw_ban : n 1, n 6= 5
Question 2
Give DFAs for the following la