Week 1 - Regular Expressions Flashcards

1
Q

List the 3 regular operations?

A

Union
Concatenation
Star

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

What is a union operation in terms of sets?

A

Joining two or more sets together into one larger set containing the items from each set.
e.g.
A = {good, bad} and B {boy, girl}
A∪B = {good, bad, boy, girl}

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

What is a concatenation operation in terms of sets?

A

Concatentating the items from one set with each of the items from a second set.
e.g.
A = {good, bad} and B {boy, girl}
A∘B = {goodboy, goodgirl, badboy, badgirl}

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

What is a star operation in terms of sets?

A

When you get all possible concatenations of the words from a finite set. This will include Ɛ. If the set isn’t empty, then the star of that set is infinite.
e.g.
A = {good, bad}
A* = {Ɛ, good, bad, goodgood, bad, badbad, goodbad, badgood, goodgoodgood, …}

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

What happens if you concatenate a language/set with an empty set?

A

You get an empty set.

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

What happens if you concatenate a language/set with a set containing only Ɛ?

A

You get the original language/set back.

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

What happens if you star an empty set?

A

You get a set containing only Ɛ.

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

What happens if you star a set containing only Ɛ?

A

You get a set containing only Ɛ.

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

TRUE OR FALSE: A language created by the union of two seperate regular languages is also a regular language.

A

TRUE, there is always a FA that will recognise a union of two regular languages. This machine can be represented by a machine containing an initial state with two Ɛ transitions, one to the machine of the first language of the union and one to the second.

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

What is the algorithm for constructing an NFA that accepts the Language L(M1)∪L(M2)?
Assume M1 is the machine that accepts L(M1) and M2 is the machine that accepts L(M2).

A

You create an initial state for the new machine, with two Ɛ transitions, one that goes to the initial state of M1 and one that goes to the initial state of M2. These two states are no longer the initial states. You must rename the states of M2 (or M1) so that the states of those machines are not the same. Follow the convention 1->1prime1, 2->2prime1 etc.. The final states of the new machine are the final states of both M1 and M2.

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

TRUE OR FALSE: The language created through concatenation of two regular languages is also a regular language?

A

TRUE.

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

What is the algorithm for constructing the NFA that accepts the language L(M1)∘L(M2)? Assume M1 is the machine that accepts L(M1) and M2 is the machine that accepts L(M2).

A

The initial state of the new machine will be the initial state of M1, and the final state(s) of M1 will now have Ɛ transition(s) to go to the initial state of M2. The final states of this new machine will be the final states of M2. You must rename the states of M2 (or M1) so that the states of the machines are not the same. Follow the convention 1->1prime1, 2->2prime1 etc..
Any concatenation of a word from L(M1) and L(M2) will follow the start of the new machine through the M1 section, then go to the M2 section and follow through that and get to the end.

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

TRUE OR FALSE: The language that is created through a star operation of a regular language is also a regular language?

A

TRUE.

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

What is the algorithm for constructing the NFA that accepts the language L(M)*? Assume M is the machine that accepts L(M).

A

Add an initial state, which has an Ɛ transition to the old initial state of M. Add transitions from all the final state(s) of M that go the the old initial state of M. Make sure that the new initial state does not have the same name as a state in M so that they can be distinct. Normally you can name it 0.
Any possible concatenation of words from a language will go through this new machine, get to the end of the machine when it reads a substring word from that concatenation, and then loop back to the start and read through the next substring word until it has read through the entire concatenated string.

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

What is a regular expression?

A

An expression that is either:
o A symbol contained in an alphabet.
o Ɛ
o an empty set
o R1∪R2 where R1 and R2 are both regular expressions
o R1∘R2 where R1 and R2 are both regular expressions
o R1* where R1 is a regular expression

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

What is L(R)?

A

The language described by a regular expression R.

17
Q

What is an easier way to write L1∘L2?

A

L1L2

18
Q

What does R+ mean?

A

RR*

19
Q

In what order do you do the regular operations in a regular expression?

A

Star, then concatenation, then union.

20
Q

Describe the language represented by 010 in computational terms.

A

{w∈{0, 1}* / w = 0…0#length m# 1 0…0#length n#, m, n >= 0}

21
Q

Describe the language represented by 0*10+ in computational terms.

A

{w∈{0, 1}* / w = 0…0#length m# 1 0…0#length n#, m>=0, n >= 1}

22
Q

TRUE OR FALSE: You can create an NFA from any regular expression.

A

TRUE, its called REGULAR expression for a reason.

23
Q

How do you create an NFA that recognises a regular expression?

A

For all languages used in the regular expression, construct a NFA. Then construct an NFA for each use of operation of the languages in the expression. Then construct an NFA for each use of operation of the regular languages created from operations in the expression. And so on until you have finished the regular expression.
e.g.
Assuming a and b are regular languages, the expression is (ab∪a)*
Create NFA for a and b. Then create an NFA for the concatentation of ab. Then create an NFA for the union of ab∪a using the NFA of ab. Then create an NFA from the * operation of the previous NFA.