CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

cse 105
SMART_READER_LITE
LIVE PREVIEW

CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ T oday's learning goals Sipser Ch 1.4, 2.1 CFG Design PDA Design Equivalence between CFG and PDA Non-context-free languages CFG Design


slide-1
SLIDE 1

CSE 105

THEORY OF COMPUTATION

Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/

slide-2
SLIDE 2

T

  • day's learning goals Sipser Ch 1.4, 2.1
  • CFG Design
  • PDA Design
  • Equivalence between CFG and PDA
  • Non-context-free languages
slide-3
SLIDE 3

CFG Design

  • Design a CFG for the language

L = {anbm | m > n ≥ 0 }

  • G=({S,T},{a,b},R,S) where R is the set of rules

S → T | ???

T → bT | b What rule is missing? A) S → aS B) S → abS C) S → aSb D) S → aabbb E) I don’t know

slide-4
SLIDE 4

CFG Design

  • Design a CFG for the language

L = {a2nban | n ≥ 0 }

  • G=({S,T},{a,b},R,S) where R is the set of rules

S → T | ???

T → b What rule is missing? A) S → aaSa B) S → aSba C) S → aSb D) S → aSa E) I don’t know

slide-5
SLIDE 5

CFG Design

  • Design a CFG for the language

L = {aibjak | i=j or j=k }

  • G=({S,T,U,V},{a,b},R,S) where R is the set of

rules

S → UT | TV

U → aUb | ε

V → bVa | ε

T → ??? What rule is missing? A) T → aT a | b B) T → aT | a C) T → aT | ε D) T → aT | bT | ε E) I don’t know

slide-6
SLIDE 6

CFG Design

  • Design a CFG for the language

L = {aibjak | i=j or j=k }

  • G=({S,T,U,V},{a,b},R,S) where R is the set of

rules

S → UT | TV

U → aUb | ε

V → bVa | ε

T → aT | ε Is this grammar ambiguous? A) No, the grammar is unambiguous B) Yes, but it can be transformed into an equivalent unambiguous grammar C) Yes, and there is no equivalent unambiguous grammar D) I don’t know

slide-7
SLIDE 7

PDA Design

  • Can we design a PDA for the same language?

L = {aibjak | i=j or j=k }

  • Can you design a deterministic PDA?
slide-8
SLIDE 8

PDAs and CFGs are equivalently expressive

Theorem 2.20: A language is context-free if and

  • nly if some nondeterministic PDA recognizes it.

Consequences

  • Quick proof that every regular language is context free
  • To prove closure of class of CFLs under a given operation, can

choose two modes of proof (via CFGs or PDAs) depending on which is easier

slide-9
SLIDE 9

Intersection

  • Consider the languages

X = {aibjak | i=j and k>1 }

Y = {aibjak | j=k and i>1 }

W = X U Y

Z = X ∩ Y = {aibjak | i = j = k >1} Which languages are context-free? A) X,Y B) X,Y,W C) X,Y,W,Z (all) D) None E) I don’t know

slide-10
SLIDE 10

Closure properties of ..

The class of regular languages is closed under

  • Union
  • Concatenation
  • Star
  • Complementation
  • Intersection
  • Difgerence
  • Reversal

The class of context-free languages is closed under

  • Union
  • Concatenation
  • Star
  • Reversal

The class CFL is not closed under

  • Intersection
  • Complement
  • Difgerence
slide-11
SLIDE 11

Non-context-free languages

  • {aibjak | i= j =k }
  • {aibjak | i<j<k }
  • { ww | w in {a,b}*}
  • Proof: Pumping Lemma for Context-Free

languages

See textbook if interested

We will not cover this in homework or tests

slide-12
SLIDE 12

Context-free languages Context-free languages Regular languages Regular languages ??? ???

slide-13
SLIDE 13

Beyond Push Down Automata

  • Can you defjne a more powerful automaton that

is able to recognize L3={aibjak | i=j=k }?

  • Can you recognize L3 with a 2PDA (Push Down

Automaton with 2 stacks)?

  • Can you recognize L4={aibjakbh | i=j=k=h } with

a 3PDA (Push Down Automaton with 3 stacks?

  • Can you recognize L4 with a 2PDA
slide-14
SLIDE 14

T uring machines

  • Unlimited input
  • Unlimited (read/write)

memory

  • Unlimited time
slide-15
SLIDE 15

T uring machine computation

  • Read/write head starts at leftmost position on tape
  • Input string written on leftmost squares of tape, rest is

blank

  • Computation proceeds according to transition function:
  • Given current state of machine, and current symbol being read
  • the machine
  • transitions to new state
  • writes a symbol to its current position (overwriting existing symbol)
  • moves the tape head L or R
  • Computation ends if and when it enters either the accept
  • r the reject state.
slide-16
SLIDE 16

Formal defjnition of TM

qreject ≠ qaccept qreject ≠ qaccept

slide-17
SLIDE 17

Reminders

  • Finish reading Sipser Chapter 2. Start Chapter 3
  • HW5 due Monday Oct 31
  • Review for Exam 2
  • T

uesday Nov 1 TBA

  • Exam 2 Wednesday Nov 2 (one week from today)
  • New seating chart: see Piazza (tonight)
  • New study guide: see Piazza (tonight)
  • Haskell 3 on CFG is out. Due Nov 7.