Week 2 - Context-Free Grammers Flashcards

1
Q

What is a context-free grammer?

A

A more powerful way of descibing languages with certain recursive syntactic features.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give an example of a rescursive syntactic feature.

A

001 = {0, 00, 000, 0…0, 0…01, 0…011, …} and so on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are context-free languages?

A

Languages defined by context-free grammers. The consist of the words that can be genertated by a given context-free grammer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

TRUE OR FALSE: All context-free languages are regular languages.

A

FALSE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

TRUE OR FALSE: All regular languages are context-free languages.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a grammer?

A

A collection of substitution rules. It generates all the strings in a language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a substitution rule?

A

A subsititution rule is a rule that is applied to symbols to help form a word (aka. derivation) in a grammer.
It consists of symbols and terminals.

Single Symbol -> Symbols and/or Terminals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does using a substitution rule obtain?

A

A string called a derivation. Derivations can be represented by a parse tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you get a word in a language using substitution rules in a grammer?

A

You start with the start variable. And then apply any appropriate rule to any smbol or combinitation of adjacent symbols. Replace thoses symbol(s) in the string with the symbols at the other side of the substitution rule. Repeat this step until there are no longer any rules that can be applied to your string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an easier way to write these two substitution rules?
A -> 01
A -> B

A

A -> 01 | B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define the context-free grammer in computional terms.

A

A context-free grammer is a tuple G = (V, Σ, R, S), where
o V is a finite set of variables
o Σ is a finite set of terminals, V ∩ Σ = Ø
o R is a finite set of rules, (a rule being composed from a variable and a string from V ∪ Σ)
o S ∈ V is the start variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you represent a derivation occuring to a string?

A

string => string

The => is important

How well did you know this?
1
Not at all
2
3
4
5
Perfectly