2.4Algebra of regular expressions and regular languages
Covers IGNOU MCS-212 §2.2.4, 2.3, Theorems 2–4, Example 15, Ex.5
Different regular expressions can describe the same language: a∗a and aa∗ both mean “one or more a‘s”. Laws of regular expressions let us simplify them and prove that two expressions are equivalent — useful when optimising a search pattern or a lexer.
Correct identities
For regular expressions R,S,T:
No.
Identity
Name / idea
1
(R+S)+T=R+(S+T), R+S=S+R, R+R=R
union is associative, commutative, idempotent
2
R+∅=R, R∅=∅R=∅
∅ is the “zero”
3
Rλ=λR=R
λ is the “one”
4
(RS)T=R(ST)
concatenation is associative
5
R(S+T)=RS+RT, (S+T)R=SR+TR
distributive laws
6
∅∗=λ∗=λ
7
R∗R∗=R∗=(R∗)∗
8
RR∗=R∗R=R+ and R∗=λ+RR∗
star unfolds
9
(R+S)∗=(R∗+S∗)∗=(R∗S∗)∗=(R∗S)∗R∗=R∗(SR∗)∗
star of a union
Each law is proved by comparing languages. For example, L(R(S+T))=L(R)(L(S)∪L(T))=L(R)L(S)∪L(R)L(T)=L(RS+RT).
Regular languages
Proof. If L={w1,…,wn}, the regular expression w1+w2+⋯+wn describes it (and ∅ describes the empty language). ■ For example, {aa,ab,ba,bb} is described by aa+ab+ba+bb and also by (a+b)(a+b): one regular language can have many regular expressions.
Not every language is regular. {anbn∣n≥0} and “strings with twice as many a‘s as b‘s” are not regular: describing them needs unlimited counting, which neither regular expressions nor finite automata can do.
Key takeaways
r=s means L(r)=L(s).
RR∗=R∗R=R+ and R∗=λ+RR∗.
(R+S)∗=R∗(SR∗)∗=(R∗S∗)∗, but (R+S)∗=R∗S∗.
Regular language = described by a regular expression; all finite languages are regular, but some languages (like anbn) are not.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Prove R+R=R and R(S+T)=RS+RT for regular expressions.
Show worked answer
L(R+R)=L(R)∪L(R)=L(R) (a set united with itself is unchanged), so R+R=R. L(R(S+T))=L(R)L(S+T)=L(R)(L(S)∪L(T)). A string xy with x∈L(R) and y∈L(S)∪L(T) is in L(R)L(S) or in L(R)L(T), and conversely; so this equals L(R)L(S)∪L(R)L(T)=L(RS+RT). Hence R(S+T)=RS+RT.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-212/automata-and-languages/algebra-of-regular-expressions-and-regular-languages/ to read this page.