EECS343, HW 4
1) (page 125, problem 12, 2pts ) Let M be the following DFSM. Use minDFSM or the table filling
algorithm discussed in class to minimize M. Remove states that are not reachable if necessary.
Initially, classes = cfw_[1, 3], [2, 4, 5, 6].
At s
Surname 1
Name
Professor
Course
Date
Coin tossing simulation
#include < stdio.h>
int flip (
);
int main ( void)
coi eads_eads, coi _tails
times_flipped = 0, 0, 0
while times flipped <100
coin_flipps =
radom.randrange (2)
if coin_flips =0
coin_heads +=1
el
Time Complexity Classes
Chapter 28
The Language Class P
L P iff
there
exists some deterministic Turing machine M
that decides L and
L,
timereq(M)
O(nk) for some k.
Well say that L is tractable iff it is in P.
Closure under Complement
Theorem: The class
More on Time Complexity
Sections 28.7 28.10
The Gap Between P and NP
Let NPL = NP (P NPC) Is NPL = ?
NPC).
Ladners Theorem
Theorem: If P NP, then NPL .
Lemma: Let B be any decidable language that is not in P. There
exists a language D that is in P and tha
Decidability and
Undecidability Proofs
Sections 21.1 21.3
Undecidable Problems
(Languages That Arent In D)
Aren t
The Problem View
The Language View
Does TM M h lt on w?
D
halt
?
H = cfw_<M w> :
cfw_<M, >
M halts on w
Does TM M not halt on w?
H = cfw_<M,
Decidability and
Undecidability Proofs
Sections 21 4 - 21 7
S ti
21.4 21.7
Is There a Pattern?
Does L contain some particular string w?
Does L contain ?
Does L contain any strings at all?
Does L contain all strings over some alphabet ?
A
= cfw_<M, w>
Decidable and Semidecidable
Languages
Chapter 20
D and SD Languages
SD
D
Context-Free
Languages
Regular
Languages
Every CF Language is in D
Theorem: The set of context-free languages is a proper
subset of D.
Proof:
Every context-free language is decidabl
Pushdown Automata
Chapter 12
Recognizing Context-Free Languages
Two notions of recognition:
(1) Say yes or no, just like with FSMs
(2) Say yes or no, AND
if yes, describe the structure
a
+
b
*
c
Just Recognizing
We need a device similar to an FSM except t
Turing Machines
Sections 17 3 17 5
17.3 17.5
Turing Machine Extensions
There are many extensions we might like to make to our
basic Turing machine model. But:
We can show that every extended machine
has an equivalent basic machine.
We can also place a bou
Turing Machines
Sections 17 6 17 7
17.6 17.7
The Universal Turing Machine
Problem: All our machines so far are hardwired.
ENIAC - 1945
The Universal Turing Machine
Problem: All our machines so far are hardwired.
Question: Can we build a programmable TM th
Parsing
Chapter 15
The Job of a Parser
Given a context-free grammar G:
Examine a string and decide whether or not it is a
E
i
ti
d d id
h th
t i
syntactically well-formed member of L(G), and
If it is, assign to it a parse tree that describes its
structure
Turing Machines
Chapter 17
Languages and Machines
SD
D
Context-Free
Languages
Regular
Languages
reg exps
FSMs
cfgs
PDAs
unrestricted grammars
Turing Machines
Grammars, SD Languages, and Turing Machines
L
Unrestricted
Grammar
SD Language
Accepts
Turing
Mac
The Church-Turing Thesis
Chapter 18
Are We Done?
FSM PDA Turing machine
Is this the end of the line?
There are still problems we cannot solve:
There
is a countably infinite number of Turing machines
since we can lexicographically enumerate all the string
1/12/2015
Outline
Introduction
EECS/MATH 343
Jing Li, Ph.D.
Case Western Reserve University
The Challenge problem
Any CS-related things that is new for you, and you
think that would be fun. But must be specific for
this course.
Examples:
Investigate so
Introduction to the Analysis
of Complexity
Chapter 27
Are All Decidable Languages Equal?
(ab)*
WWR
= cfw_wwR : w cfw_a, b*
WW
= cfw_ww : w cfw_a, b*
b
SAT
= cfw_w : w is a wff in Boolean logic and w is satisfiable
The Traveling Salesman Problem
15
10
NP-Completeness
Sect o s 8 5, 8 6
Sections 28.5, 28.6
NP-Completeness
A language L might have these properties:
1.
1 L is in NP
NP.
2. Every language in NP is deterministic,
polynomial-time reducible to L.
L is NP-hard iff it possesses property 2.
An NP h
EECS 343 EXAM 2. Please write clearly.
Name:
Case ID:
1. (25pts) Construct a regular expression from this FSM step by step.
See textbook page 137 Example 6.7.
2. (25pts) State whether L=cfw_anbm | n, m >=0, n-m=5 is regular or not. Prove your statement.
a
EECS343 Entry quiz
Name:
Case netID
1. List the elements of each of the following sets:
a. (2pts) P(cfw_a, b) - P(cfw_a, c):
a. cfw_b, cfw_a, b
b. (2pts) cfw_x : y (z (x = y + z) (y < 5) (z < 4)
a. 0, 1, 2, 3, 4, 5, 6, 7
2. let Rp be a binary relation on
EECS343, HW 7
1)
(modified from page 247, problem 13.b , 3pts )For each of the following grammars G, show that G is
ambiguous. Then find an equivalent grammar by 1) eliminating -rules and 2) by eliminating
symmetric rules.
b) (cfw_S, a, b, cfw_a, b, R, S)
EECS343, HW 10
1) (page 322, 1.a and 1.d, 4pts) Give a decision procedure to answer each of the following questions:
a) Given a regular expression and a PDA M, is the language accepted by M a subset of the
language generated by ?
Observe that this is true
EECS343, HW 9
1) (page 310, 1. a-c, e-g, 3pts) For each of the following languages L, state whether L is regular, contextfree but not regular, or not context-free and you DONOT need to show the proof.
a) cfw_xy : x, y cfw_a, b* and |x| = |y|.
Regular. L =
EECS343, HW 8
1) (page 278, problem 4, modified, 6pts )Consider the language L = L1 L2, where L1 = cfw_wwR : w cfw_a, b*
and L2 = cfw_anb*an: n 0.
a) List the first four strings in the lexicographic enumeration of L?
b) Write a context-free grammar to gen
EECS343, HW 3
1) (page 122, problem 5, 3pts ) Consider the following NDFSM M:
For each of the following strings w, determine whether w L(M):
a) aabbba.
Yes
b) bab.
No
c) baba.
Yes
2) (page 123, problem 7, 3pts ) Show an FSM (deterministic or nondeterminis
EECS 343
HW 1 Solutions
1) (page 804, problem 3)
Prove each of the following:
a) A (B C D) = (A B) (A D) (A C).
Distributivity
A (B C D) = (A B) (A D) (A C).
Set union distributes over set intersection.
b) A (B C A) = A.
Let: D = B C
So:
A (D A) = A.
Abso
EECS343, HW 5
1) (page 182, problem 1, (c,f,h,j,k,n) , 3pts ) For each of the following languages L, state whether or not
L is regular. You DONOT need to show the proof.
c) cfw_aibj : i, j 0 and |i j| 5 0.
Regular. Note that i j 5 0 iff i 5 j. L can be ac
EECS343, HW 2
1) For each of the following languages L, give a simple English description. Show two strings that are in
L and two that are not (unless there are fewer than two strings in L or two not in L, in which case
show as many as possible).
a) L = c
EECS343, HW 6
4) (page 196, problem 1, (d, ) , 3pts ) Define a decision procedure for each of the following questions. Argue
that each of your decision procedures gives the correct answer and terminates.
d) Given two regular expressions, and , do there ex
Finite State Machines
Chapter 5
Outline
First model of computation definition of
computation,
deterministic Finite State
Machines/Automata (FSM/DFSM/DFA)
Design of FSM
N d t
Nondeterministic Finite State Machines
i i ti Fi it St t M hi
(NFSM/NFA)
Finit
Context-Free and
Noncontext-Free Languages
Chapter 13
Languages That Are and
Are Not Context-Free
a*b* is regular.
AnBn = cfw_anbn : n 0 is context-free but not regular.
AnBnCn = cfw_anbncn : n 0 is not context-free.
Languages and Machines
The Regular and
Algorithms and Decision
Procedures for
Context-Free Languages
Chapter 14
Decision Procedures for CFLs
Membership: Given a language L and a string w, is w in L?
Two approaches:
If L is context-free, then there exists some context-free
grammar G that gener
Finite State Machines
Chapter 5
Outline
Deterministic Finite State Machines/
Automata (FSM/DFSM/DFA)
First model of computation
Definition and design of FSM
Nondeterministic Finite State Machines
(NFSM/NFA)
Definition and design
Equivalence of the t
Finite State Machines
State Minimization
Chapter 5
Outline
State minimization is helpful
Link to structure of its language:
equivalence relation for strings given a
language
Minimization algorithms for a given
machine
State Minimization
Consider:
Is th