Eksamen Flashcards

1
Q

If a language is context-free, is it then regular?

A

No.

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

Signs that a language is context-free:

A
  • You can describe it with a PDA.
  • You can describe it with a context-free grammar:

E.g. we have the language (c | ɛ) a (c | ɛ) b

(c | ɛ) can be made into a non-terminal called C.

S -> CaCb

C -> c | ɛ

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

Signs that a language is regular:

A
  • You can describe it with a DFA or a NFA.
  • You can describe it with a regular expression.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What can be in Chomsky-normal-form?

A

All context-free grammars/languages.

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

Can every:

pushdown-automata

be converted to a

deterministic pushdown-automata?

A

No.

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

Signs that a language isn’t regular.

A
  • By using the pumping lemma. (It is hard to do if you don’t know that it isn’t regular) (Often used to prove that it isn’t regular not so much to find out if it isn’t regular)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List the four kinds of scope rules:

A
  1. Full Static scope rules
  2. Full Dynamic scope rules
  3. Mixed where envV is static and envP is dynamic
  4. Mixed where envV is dynamic and envP is static
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Dynamic scope rules are:

A

When the environtment from call time is used

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

Static scope rules are:

A

When the environtment from declaration time is used

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

What are the three most common parameter mechanisms?

A
  1. Call by value.
  2. Call by reference.
  3. Call by name.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is call/pass-by value?

A

The actual parameter is evaluated at call time.

E.g.

int func(a) { return a + 1 }

func(2 + 3)

Behind the scenes this happens: a = 5

So the return statement reads return a + 1;

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

What is call/pass-by reference?

A

No new variable is declared at call-time, instead the parameter is used directly.

E.g.

int x = 2 + 3;

int func(a) { a = a + 1; }

func(x);

Print(x); // x = 6

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

What is call/pass-by name?

A

The parameter passed isn’t evaluated before it is used in the function.

E.g

int func(a) { return a + 1; }

func(2 + 3)

The return statement in the body of func will read

return 2 + 3 + 1

instead of

return a + 1; (call by value).

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

Which operations are regular languages closed under?

A

complement (A’),

intersection(A ∩ B),

union(A U B),

concatenation(A o B),

Kleene star A*

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

What does Σ (Sigma) describe?

A

It describes an alphabet.

An alphabet is a finite set of symbols.

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

What is δ? (Delta)

A

The transition function.

Q x Σ –> Q (describes which state you go to and from with a given input.)

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

What is the definition of a Finite Automaton? (which tuples does it contain)

A

Q = is a finite set of states.

Σ = is a finite alphabet.

δ = Transitions: Q x Σε –> P(Q). (describes which state you go to and from with a given input.)

q0 = Initial state

F = Final set of states

18
Q

How to define a language

A
  1. Med en grammatik; Productions ( S= aSa | epsilon; )
  2. Hvis regulært: regular expressions (problematisk)
  3. Definition, setup og regler: L(M1) = { w ∈ {0, 1} | extra rules }
19
Q

What is the pumping length?

A

A natural number p ≤ |w|

A natural number, p, for a regular laguage for which it is true that any word in the language longer than p, can be pumped.

20
Q

Regular expression pumping:

What are the conditions xyz must satisfy for the language to be regular?

A

w = xyz

xyiz is in the language for all “i ϵ N(natural numbers)” (no matter what “i” is xyiz is in the language)

xz can always be ɛ.

|y| > 0 (cannot be ɛ)

|xy| ≤ p

21
Q

What are the 4 steps in the game with the Demon?

A
  • You play a game against a demon. The demon tries to prove the language is regular. You try to disprove it.*
    1. Demon chooses p (You don’t know it usually)
    2. I choose a word (that must have at least p length, usually define by using p)
    3. Demon splits w into xyiz in the best possible way for him
    4. I choose i that must be at least zero.
22
Q

What is a derivation?

A

=> without star means that you are not allowed to dig deeper.

E.g: The grammar: A -> B | AA | epsilon, B -> a | b ;

A => aba, means can you get “aba” from A where you don’t dig deeper. Since “a” and “b” are in B you can not access it from A without going futher.

=>* with star means that you are allowed to go futher.

E.g The grammar from above.

A=>* aba is allowed since from A you can go to B and find “a” and “b”.

23
Q

What is the definition of a grammar?

A

It is a tuple consisting of G = ( V, Σ, R, S )

  • V is a finite set of variables / nonterminals*
  • Σ is a finite set of terminals*
  • R is a finite set of rules (a variable and a string)*
  • S is the start variable*

Example of a grammar:

  • S -> aA ;*
  • A -> aa;*
24
Q

What is the definition of a context-free grammar?

A

A grammar where all production rules (Nonterminal -> something) can be applied regardless of the context, in other words there are no conditions to when a rule can be used.

It is the opposite of a context-sensitive grammar.

25
Q

How do you convert a DFA into a CFG?

A

Turn the states: q0, q1, q2, q3 into rules: R0, R1, R2, R3

By looking at the automata transition function (δ(delta)) you can directly translate it into a rule.

26
Q

How would you prove that a phrase is ambiguous?

A

Create 2 different and valid parse trees from the phrase.

27
Q

When is a Context-Free Grammar in Chomsky Normal Form?

A

When just one of these rules are fulfilled for all productions:

A -> BC (when the nonterminal A becomes two nonterminals)*

A -> a (when the nonterminal A becomes one terminal)*

S -> ɛ (s is the only symbol allowed to be epsilon)

*any nonterminal can only be two nonterminals or one terminal

28
Q

How is the transition represented on a PDA model

A

(input, pop) -> push

29
Q

What does SOS stand for?

A

Structural Operational Semantics

30
Q

What are the two types of Structural Operational Semantics? (SOS)

A

Big-Step semantics

Small-Step semantics

31
Q

What is a tuple?

A

A chain of functions that uses eachothers outputs, that acts as one function.

E.g.

A() returns x, x is used as input in B(x), y is the output of B and is used as the input of C(y)

32
Q

Define an Equivalence relation:

A

R is an equivalence relation if A is nonempty and R is reflective, symmetric and tranitive.

E.g.

x ≡myRelation y if specifiedConditions.

33
Q

An equivalence relation is reflective if:

A

If the equivalence relation is used to compare something with itself and it returns true if they are the same.

E.g.

A ≡customName A

If it evaluates A to be the same as itself it is reflective. (They are almost always reflective)

34
Q

An equivalence relation is symmetric if:

A

If the equivalence ≡myRelation specifies that:

if x = y then y = x

Then ≡myRelation is symmetric

35
Q

An equivalence relation is transitive if:

A

if ≡myRelation specifies that if:

x = y and y = z then x is also = z

36
Q

Context-free pumping:

What are the conditions of uvxyz?

A

uxz can always be ɛ.

|vy| > 0 (only one of them can be ɛ)

|vxy| ≤ p

if uvixyiz = w then w ∈ L for i ∈ N

37
Q

What does GNFA mean and are the rules for its states?

A

A generalized nondeterminstic finite automaton.

  1. Start state:
    1. Arrows pointing at every other state.
    2. No arrows pointing at it.
  2. Final state
    1. Only one final state.
    2. Arrows pointing at it from every other state.
    3. No arrows pointing from it.
  3. Regular states
    1. Has to point to the final state.
    2. Has to point to every other regular state.
    3. Has to point to itself.
38
Q

Hieracy of grammar, languages and automatas.

A
39
Q

Context-free pumping:

How do you describe the pumping process in the exam? (without mentioning the demon)

A
  1. Assume L to be a context-free language.
  2. Let p ≥ 0 be a pump length for L and select a string s ∈ L so that |s| ≥ p.
  3. Show for any split of s of the form uvxyz that it does not comply with the conditions 1-3 of the Pumping Lemma, i.e., that we do not have
    1. uvixyiz ∈ L for i ∈ N
    2. |vy| > 0
    3. |vxy| ≤ p
  4. Therefore we can conclude that L is not context-free.
40
Q

What is the definition of a PDA?

A

A PDA is a touple: P = (Q, Σ, δ, γ, q0, F)

Q = finite set of states.

Σ = finite alphabet.

δ (delta) = transition function.

γ = finite stack alphabet.

q0 = initial state.

F = finite set of final states.

41
Q

What is the definition of a GNFA?

A

A GNFA is a touple (Q, Σ, δ, qs. qa)

Q = finite set of states

Σ = finite input alphabet

δ = transition function

qs = start state

qa = final state