Week 1 - Regular Expressions Flashcards
List the 3 regular operations?
Union
Concatenation
Star
What is a union operation in terms of sets?
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}
What is a concatenation operation in terms of sets?
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}
What is a star operation in terms of sets?
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, …}
What happens if you concatenate a language/set with an empty set?
You get an empty set.
What happens if you concatenate a language/set with a set containing only Ɛ?
You get the original language/set back.
What happens if you star an empty set?
You get a set containing only Ɛ.
What happens if you star a set containing only Ɛ?
You get a set containing only Ɛ.
TRUE OR FALSE: A language created by the union of two seperate regular languages is also a regular language.
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.
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).
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.
TRUE OR FALSE: The language created through concatenation of two regular languages is also a regular language?
TRUE.
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).
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.
TRUE OR FALSE: The language that is created through a star operation of a regular language is also a regular language?
TRUE.
What is the algorithm for constructing the NFA that accepts the language L(M)*? Assume M is the machine that accepts L(M).
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.
What is a regular expression?
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