Day20-ClassNotes - Rose

advertisement

MA/CSSE 474 Day 20 Announcements and Summary

Announcements:

1) The online slides form yesterday now include solutions to some of the in-class exercises. If you don't see tem, perhaps your web browser has cached the file.

2) HW 8 is due Monday, Jan 20, Exam 2 Tuesday Jan 21, HW 9 Friday Jan 24 (assignment available this weekend). HW10 Jan 28. a) Unlike previous Monday assignments, HW8 is not short, since you will have had extra time to work on HW6 and 7 (because of the long break and postponed assignments), so you should be able to start HW8 earlier than the weekend.

3) Exam2 material: 5.1-5.8, 6.1-6.4, 8.1-8.6, 9.1-9.2, HW 1-8. You can bring 2 double-sided sheets of paper. a) After the Exam 1 "time overrun" on Exam 1, I decided that there is no reasonable induction problem at the (high) level of this course over material we have seen that fits well on a 50-minute test, so I I will wait until the final exam.

Main ideas from today Context-Free Grammars

1) CFG G = (V, G, R, S), where (this is from yesterday) a)

is the terminal alphabet; it contains the symbols that make up the strings in L(G), and b) N is the nonterminal alphabet a set of working symbols that G uses to structure the language. These symbols c) d) disappear by the time the grammar finishes its job and generates a string.

(Note:

∩ N =

.) Rule alphabet: V =

∪ N

R: A set of productions of the form A

G has a unique start symbol, S ∊ N

 β, where A ∊ N and β ∊ V*.

2) Notation conventions: a,b,c ∈ Σ, A,B,C ∈ N, α,β,γ,x,y,z ∈ V*

3) One derivation step: x

G

y iff ∃ α,β,γ ∈ V*, A ∈ N ((x =

A

) ∧ (A

 

∈ R) ∧ (y =

  

))

4)

G

* is the reflexive, transitive closure of

G

5) When to stop a derivation: (either of these) a) The working string no longer contains any nonterminal symbols (including, when it is

).

Often we just write the productions. The lhs of the first production is the start symbol. Anything that appears on the lhs of some production is assumed to be a nonterminal b) There are nonterminal symbols in the working string but none of them is in a substring that is the left-hand side of any rule in the grammar.

6) The language defined by a grammar: L(G) = {w

 

* : S

G

* w} a) If G is S

aSb, S

 

, What is L(G)? b) If S x

G

α, we say that α is a sentential form of G. If α ∊T*, it is a sentence (sometimes called a word) in L(G)

7) A language L is context-free if there is some context-free grammar G such that L = L(G). CFL

8) Write CFGs for these languages:

Bal a m b n : m>= n

9) In a regular grammar, every rule (production) in R must have a right-hand side that is a)

, b) or a single terminal, c) or a single terminal followed by a single nonterminal.

S

bS, S

aT

T

aS, T

b, T

 ε

10) L is a regular language if and only if L = L(G) for some regular grammar G.

11) A rule is recursive iff it is X

w

1

Yw

2

, where:

Y

* w

3

Xw

4

for some w

1

, w

2

, w

3

, and w

4

in V*.

12) A grammar G is recursive iff G contains at least one recursive rule

13) A rule in a grammar G is self-embedding iff it is :

X

w

1

Yw

2

, where Y

* w

3

Xw

4

and both w

1 w

3

and w

4 w

2

are in

 + .

14) A grammar is self-embedding iff it contains at least one self-embedding rule.

15) If a grammar G is not self-embedding then L(G) is regular.

16) If a language L has the property that every grammar that defines it is self-embedding, then L is not regular.

17) Examples: a) Let L = {w

{a, b}*: # a

(w) = # b

(w)}. Find a CFG G such that L = L(G) b) A grammar for arithmetic expressions: E

E + E, E

E

E, E

(E), E

id .

Derive id + id * id.

18) BNF is a variation on CFGs that is often used to describe the syntax of real programming languages.

19) I ran out of time for creating these notes; there is space below for you to write more notes if you wish.

Download