General Flashcards

1
Q

What is the closure property?

A

If two regular languages are combined using an operator, then the resulting language is also regular

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

Name the closure properties

A

Union, intersect, complement, difference, reversal, Kleene, concatenation, homomorphism, inverse homomorphism

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

What is the Kleene operator?

A

The set of all finite sequences of the language

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

What is homomorphism?

A

A function that converts one language into another. Such as ab = 0, bbb = 1

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

How does one unionize two DFA’s?

A

lump all starting states as one, and each letter added leads to a new lumped state. If one of the languages’ states is an accepting state, the lumped union state is also regular

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

How does one create a complement DFA?

A

Swap all accepting states to non accepting states, as well as all non accepting states to accepting states

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

How does one create the intersection of two DFA’s

A

Lump the initial states together, then each letter creates a new lumped state. This is the same as union, except a state is only accepting if both languages states are accepting.

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

What is L1 - L2 equivalent to?

A

L1 intersect L2^c

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

How does one create a reversed DFA, given a DFA?

A

Create a new initial state, and link it to all of the accepting states. Then, swap all of the arrows, and make the old initial state the accepting state, and the old accepting states non accepting states.

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

What is a homomorphism?

A

A string homomorphism is a function which substitute each symbol in ∑
(main alphabet) by a corresponding string in T (another alphabet)

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

What is a counterexample for Infinite union of finite sets is regular.

A

Sol: all sets: {01}, {0011}, {000111} … are regular but their union {01}∪{0011}∪{000111} … will be {0n​ ​1n​ ​ | n for n>0} which is not regular.

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

Find a counterexample for: If A is regular and A ∪ B is regular, then B is necessarily regular.

A

Sol: A = 01 and B = 0n​ ​1n​ ​ A is regular, A ∪ B = 01 is regular, but B is not
regular

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

Is this regular? L = the number of 0’s in w is 7k (for some k) and the number of 1’s in w is 5r (for some r)

A

Sol: It is regular, you can create a DFA with 35 states which captures all possible situations for the number of 0’s and 1’s (5 reminders for 5r, and 7 reminders for 7k).

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

Is this regular? L=​{​w, t​he number of 0’s in​ w ​is less than the number of 1’s}

A

Sol: it is not regular and we can prove it using pumping lemma:
1. Assume n is the pumping length.
2. Let w = 0n​ ​1n​ +1,​ (note: the |w| >= n).
3. w = xyz, so that |xy| <= n and |y| >=1, with these conditions, y should be in 0 part of the string: 0r​ ​ (r>=1),
4. So if we choose k = 2, then xyyz will be 0n​ +r1​ n​ +1​, which is not in the language (because n+r >= n+1, the number of zero’s will be greater or equal to the number of ones)

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

Is this regular? L={a^n b^n, where m≠n and m, n ≥ 0}

A

Sol: Not regular, we can prove using closure properties.
L1 = 01 is regular, assume L is also regular, then L1 - L should be regular (because regular languages are closed under set difference).
L1-L = 0n​ ​1n​ ​ which we know is not regular. It is a contradiction. Then L is not regular

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

Is this regular? L={​ wxwR​, where w,x∈{a,b}*and w, x >0} wR​ ​ is the reverse of string w}

A

Sol: The important thing to note about this language is the length of x is greater than 0, i.e., |x| > 0. So any string that starts and ends with the same character is acceptable by language and the remaining string becomes x.

17
Q

Is this regular? Assume L = {w, where w has equal number of 0’s and 1’s}, init (L) = {set of all prefixes of every string w∈L}

A

Sol: assume w is a string with equal number of 0’s and 1’s, then all prefixes of strings like w, will be all binary strings! (there will be no constraints on the number of zeros and ones)

18
Q

Is the following string regular? www, where w is a binary string

A

Sol: it is not regular and we can prove it using pumping lemma:
1. Assume n is the pumping length.
2. Let w = 0n​ ​1n​ 0​ n​ ​1n​ 0​ n​ ​1n​ ,​ (note: the |w| >= n).
3. w = xyz, so that |xy| <= N and |y| >=1, with these conditions, y should be in first 0 part of the string: 0r​ ​ (r>=1),
4. So if we choose k = 2, then xyyz will be 0​n+r1​ n​ ​0​n​1n​ ​0​n​1n​ ​, which is not in the language. Because you cannot divide the resulting string to three strings v all identical (vvv).

19
Q

Regular? L={​ 0m​ ​1n​​ 0m​, where m,n ≥ 0}

A

Sol: it is not regular and we can prove it using pumping lemma:
1. Assume N is the pumping length.
2. Let w = 0N​ ​1​N​0N​ ,​ (note: the |w| >= N).
3. w = xyz, so that |xy| <= N and |y| >=1, with these conditions, y should be in 0 part of the string: 0r​ ​ (r>=1),
4. So if we choose k = 2, then xyyz will be 0​N+r1​ N​ 0​ N​ ,​ which is not in the language (because N+r != N, the number of zero’s in the first part is not equal to the number of zeros at the end of the string)

20
Q

Regular? L = {​ ​w, where w​ has at least as many occurrences of (10)’s as (01)’s }

A

Yes

21
Q

How does one use inductive proof to determine the correctness of a DFA?

A
  1. Assume base case of epsilon is handled
  2. Show that for all strings of length k, there exists one of length k+1. To do this, show that the transition(q0, w) -> all other state invariants. ie wr -> where r = all elements in the language for each state.
  3. Show that the accepting states are the correct ones
22
Q

Describe Chomsky Normal Form

A

All variables either end in a single terminal, or two Variables.

23
Q

How to turn a CFG into CNF

A

First, simplify the CFG. Then you must isolate the variables from the terminals, by turning terminals into variables that lead to a single terminal. Afterwards, convert all variables in a chain of 3 or longer into 2 by lumping 2 into 1 ie ABC -> AD, D = BC

24
Q

How do you simplify a CFG

A
  1. Eliminate useless symbols
  2. Eliminate epsilon productions
  3. Eliminate unit productions ie A -> B
25
Q

How do you remove useless symbols

A

Remove non generating symbols, then non reachable symbols.

26
Q

What are CFL’s not closed under

A

Intersect
Difference
Complement

27
Q

What are CFL’s closed under

A

Union
Concatenation
Kleene
Substitution
Homomorphism
Inverse homomorphism
Reversal

28
Q

Is the intersect of a CFL and a regular language a CFL?

A

Yes