Identity Rules for Regular Expression in Automata



Regular expressions (RE) are useful tools used in automata theory for pattern matching. Identities of regular expressions are relations that are always true for every regular expression. These identities help simplify and understand complex regular expressions.

In this chapter, we will highlight some rules which are known as identities rules in regular expressions and see some examples for a better understanding.

Regular Expression in Automata

To get the concept of identity rules, let us get a brief idea of RE or Regular Expressions. The regular expressions are the most efficient way to represent any language, used to check and match character combinations in strings. They are also known as Regular languages, and are used by the string searching algorithm to find operations on a string.

Identity Relations

An identity is a tautologically or true relation in mathematics, such as (a + b)2 = a2 + 2ab + b2. These identities can be used to prove other problems and are also true for every RE.

In this section, we will discuss identities related to RE, including those that are true for every RE.

Basic Identities

Identity Name Rule Description
Null Set Identity ∅ + R = R + ∅ = R ∅ + R = ∅∪R = R
Null Set Multiplication Identity ∅R = R∅ = ∅ ∅R = ∅∩R = ∅
Empty String Identity ΛR = RΛ = R Concatenating the empty string with any string in results in the same string.
Star of Empty String and Null Set Λ* = Λ
* = Λ
The star of the empty string is just the empty string repeated.
Idempotent Law R + R = R Adding the same set to itself results in the same set.
Star Multiplication Law R* R* = R* Repeating R any number of times is the same as repeating it any number of times.
Concatenation Law R* R = RR* A string from R followed by zero or more repetitions of R is the same as zero or more repetitions of R followed by a string from R.
Star of Star Law (R* )* = R* Repeating a repeated pattern any number of times is still just repeating the pattern any number of times.
Empty String and Star Λ + RR* = R* An empty string or any repetition of R is the same as zero or more repetitions of R.
Distributive Law (P + Q)R = PR + QR A string from P or Q followed by R is the same as a string from P followed by R or a string from Q followed by R.

Examples of Regular Expression Identities

Let us see some examples and solutions that can be solved through these laws.

Question 1: Prove that (1 + (100)*) + (1 + (100)*)(0 + (10)*) (0 + (10)*)* = (10)* (0 + (10)*)*

Solution

Start with the left-hand side (LHS)

$$\mathrm{1 \:+\: (100)^{*}) \:+\: (1 \:+\: (100)^{*})(0 \:+\: (10)^{*}) (0 \:+\: (10)^{*})^{*}}$$

Apply the identity: Λ + RR* = R*

$$\mathrm{(1 \:+\: (100)^{*})(Λ \:+\: (0 \:+\: (10)^{*}) (0 \:+\: (10)^{*})^{*})}$$

Simplify using: Λ + RR* = R*

$$\mathrm{(1 \:+\: (100)^{*}) (0 \:+\: (10)^{*})^{*}}$$

Combine using distributive law −

$$\mathrm{1(0 \:+\: (10)^{*})^{*}}$$

So, the result is,

$$\mathrm{(10)^{*} (0 \:+\: (10)^{*})^{*}}$$

Thus, LHS equals the right-hand side (RHS).

Question 2: Prove that 10 + (1010)* [Λ + (1010)*] = 10 + (1010)*

Solution

Start with the left-hand side (LHS)

$$\mathrm{10 \:+\: (1010)^{*}\: [Λ \:+ \:(1010)^{*}]}$$

Apply the identity −

$$\mathrm{Λ \:+\: RR^{*} \:=\: R^{*}}$$

$$\mathrm{10 \:+\: (1010)^{*} \:+\: (1010)^{*}\: (1010)^{*}}$$

Simplify using

$$\mathrm{ΛR \:=\: R \:\:and\:\: RR \:=\: R}$$

$$\mathrm{10 \:+\: (1010)^{*}}$$

Thus, LHS equals the right-hand side (RHS).

Question 3: Prove that (PQ)* P = P(QP)*

Solution

Start with the left-hand side (LHS)

$$\mathrm{(PQ)^{*} \:P}$$

Expand (PQ)*

$$\mathrm{\{Λ, \:PQ,\: PQPQ,\: PQPQPQ,\: \dotso\}}$$P

Concatenate P with each element

$$\mathrm{\{P,\: PQP,\: PQPQP,\: PQPQPQP,\: \dotso\}}$$

Factor P,

$$\mathrm{P\{Λ,\: QP,\: QPQP,\: QPQPQP,\: \dotso\}}$$

Recognize the set,

$$\mathrm{P(QP)^{*}}$$

Thus, LHS equals the right-hand side (RHS).

Conclusion

In this chapter, we explained one of the most important concept in automata theory, i.e., the concept of regular expressions. Regular expressions are used to write expressions or languages in such a form that can be expanded. There are some rules associated with regular expressions that we explained in this chapter with the help of a set of examples.

Advertisements