CS 208: and Logic Properties for Regular Languages

Ashutosh Trivedi

b a a

start A ∀x(La(x) → ∃y.(x < y) ∧ Lb(y)) B

b

Department of Computer Science and Engineering, Indian Institute of Technology Bombay.

Ashutosh Trivedi – 1 of 13 Ashutosh Trivedi Regular Languages Closure Properties Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A} 4. : AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton.

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties 3. Complementation: A = {w : w 6∈ A} 4. Concatenation: AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a set being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B}

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties 4. Concatenation: AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a set being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A}

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a set being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A} 4. Concatenation: AB = {wv : w ∈ A and v ∈ B}

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties Define the notion of a set being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A} 4. Concatenation: AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on.

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure.

Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A} 4. Concatenation: AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a set being closed under an operation (say, N and ×).

Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties Regular Languages: Properties

Definition (Regular Languages) A language is called regular if it is accepted by a finite state automaton. Let A and B be languages (remember they are sets). We define the following operations on them: 1. Union: A ∪ B = {w : w ∈ A or w ∈ B} 2. Intersection: A ∩ B = {w : w ∈ A and w ∈ B} 3. Complementation: A = {w : w 6∈ A} 4. Concatenation: AB = {wv : w ∈ A and v ∈ B} 5. Closure (Kleene Closure, or Star): ∗ A = {w1w2 ... wk : k ≥ 0 and wi ∈ A}. In other words: ∗ i A = ∪i≥0A where A0 = ∅, A1 = A, A2 = AA, and so on. Define the notion of a set being closed under an operation (say, N and ×). Theorem The class of regular languages is closed under union, intersection, complementation, concatenation, and Kleene closure. Ashutosh Trivedi – 2 of 13 Ashutosh Trivedi Regular Languages Closure Properties Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2.

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2).

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness:

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties – L1 ∪ L2 is regular since there is a DFA accepting this language.

Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Union Lemma The class of regular languages is closed under union.

Proof.

– Prove that for regular languages L1 and L2 that L1 ∪ L2 is regular.

– Let M1 = (S1, Σ, δ1, s1, F1) and M2 = (S2, Σ, δ2, s2, F2) be DFA for L1 and L2. – DFA Construction: (the Product Construction) We claim the DFA M = (S1 × S2, Σ, δ, (s1, s2), F) where

– δ((s1, s2), a) = (δ1(s1, a), δ2(s2, a)) for all s1 ∈ S1, s2 ∈ S2, and a ∈ Σ, – F = (F1 × S2) ∪ (S1 × F2).

accepts L1 ∪ L2 i.e. L(M) = L(M1) ∪ L(M2). – Proof of correctness: For every string w, we have ˆ ˆ ˆ 1. δ((s1, s2), w) = (δ1(s1, w), δ2(s2, w)) ˆ ˆ ˆ 2. δ((s1, s2), w) ∈ F iff δ1(s1, w) ∈ F or δ2(s2, w) ∈ F.

– L1 ∪ L2 is regular since there is a DFA accepting this language.

Ashutosh Trivedi – 3 of 13 Ashutosh Trivedi Regular Languages Closure Properties – REGEX Construction: We claim the REGEX E = E1 + E2

accepts L1 ∪ L2, i.e. L(E1 + E2) = L(E1) ∪ L(E2). – Proof of correctness: trivial by definition of regular expressions.

– L1 ∪ L2 is regular since there is a REGEX E1 + E2 accepting this language.

Closure under Union via RegEx

Lemma The class of regular languages is closed under union.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1 ∪ L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2.

Ashutosh Trivedi – 4 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Proof of correctness: trivial by definition of regular expressions.

– L1 ∪ L2 is regular since there is a REGEX E1 + E2 accepting this language.

Closure under Union via RegEx

Lemma The class of regular languages is closed under union.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1 ∪ L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1 + E2

accepts L1 ∪ L2, i.e. L(E1 + E2) = L(E1) ∪ L(E2).

Ashutosh Trivedi – 4 of 13 Ashutosh Trivedi Regular Languages Closure Properties – L1 ∪ L2 is regular since there is a REGEX E1 + E2 accepting this language.

Closure under Union via RegEx

Lemma The class of regular languages is closed under union.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1 ∪ L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1 + E2

accepts L1 ∪ L2, i.e. L(E1 + E2) = L(E1) ∪ L(E2). – Proof of correctness: trivial by definition of regular expressions.

Ashutosh Trivedi – 4 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Union via RegEx

Lemma The class of regular languages is closed under union.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1 ∪ L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1 + E2

accepts L1 ∪ L2, i.e. L(E1 + E2) = L(E1) ∪ L(E2). – Proof of correctness: trivial by definition of regular expressions.

– L1 ∪ L2 is regular since there is a REGEX E1 + E2 accepting this language.

Ashutosh Trivedi – 4 of 13 Ashutosh Trivedi Regular Languages Closure Properties – DFA Construction: We claim the DFA

0 0 0 M = (S, Σ, δ, s0, F ) where F = Q \ F

accepts L, i.e. L(M0) = {w : w 6∈ L(M)}. – Proof of correctness: For every string w, we have ˆ ˆ 0 1. δ(s0, w) 6∈ F iff δ(s0, w) ∈ F . – L is regular since there is a DFA accepting this language.

Closure under Complementation

Lemma The class of regular languages is closed under complementation.

Proof. – Prove for arbitrary L that L is a regular languages.

– Let M = (S, Σ, δ, s0, F) be a DFA accepting L.

Ashutosh Trivedi – 5 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Proof of correctness: For every string w, we have ˆ ˆ 0 1. δ(s0, w) 6∈ F iff δ(s0, w) ∈ F . – L is regular since there is a DFA accepting this language.

Closure under Complementation

Lemma The class of regular languages is closed under complementation.

Proof. – Prove for arbitrary regular language L that L is a regular languages.

– Let M = (S, Σ, δ, s0, F) be a DFA accepting L. – DFA Construction: We claim the DFA

0 0 0 M = (S, Σ, δ, s0, F ) where F = Q \ F

accepts L, i.e. L(M0) = {w : w 6∈ L(M)}.

Ashutosh Trivedi – 5 of 13 Ashutosh Trivedi Regular Languages Closure Properties – L is regular since there is a DFA accepting this language.

Closure under Complementation

Lemma The class of regular languages is closed under complementation.

Proof. – Prove for arbitrary regular language L that L is a regular languages.

– Let M = (S, Σ, δ, s0, F) be a DFA accepting L. – DFA Construction: We claim the DFA

0 0 0 M = (S, Σ, δ, s0, F ) where F = Q \ F

accepts L, i.e. L(M0) = {w : w 6∈ L(M)}. – Proof of correctness: For every string w, we have ˆ ˆ 0 1. δ(s0, w) 6∈ F iff δ(s0, w) ∈ F .

Ashutosh Trivedi – 5 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Complementation

Lemma The class of regular languages is closed under complementation.

Proof. – Prove for arbitrary regular language L that L is a regular languages.

– Let M = (S, Σ, δ, s0, F) be a DFA accepting L. – DFA Construction: We claim the DFA

0 0 0 M = (S, Σ, δ, s0, F ) where F = Q \ F

accepts L, i.e. L(M0) = {w : w 6∈ L(M)}. – Proof of correctness: For every string w, we have ˆ ˆ 0 1. δ(s0, w) 6∈ F iff δ(s0, w) ∈ F . – L is regular since there is a DFA accepting this language.

Ashutosh Trivedi – 5 of 13 Ashutosh Trivedi Regular Languages Closure Properties Proof. – DFA based via product construction, – Using De Morgan’s laws.

Closure under Intersection

Lemma The class of regular languages is closed under intersection.

Ashutosh Trivedi – 6 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Using De Morgan’s laws.

Closure under Intersection

Lemma The class of regular languages is closed under intersection.

Proof. – DFA based via product construction,

Ashutosh Trivedi – 6 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Intersection

Lemma The class of regular languages is closed under intersection.

Proof. – DFA based via product construction, – Using De Morgan’s laws.

Ashutosh Trivedi – 6 of 13 Ashutosh Trivedi Regular Languages Closure Properties Proof.

– Prove for arbitrary regular languages L1 and L2 that L1.L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1.E2

accepts L1.L2, i.e. L(E1.E2) = L(E1).L(E2). – Proof of correctness: trivial by definition of regular expressions.

– L1.L2 is regular since there is a REGEX E1.E2 accepting this language.

Closure under Concatenation

Lemma The class of regular languages is closed under concatenation.

Ashutosh Trivedi – 7 of 13 Ashutosh Trivedi Regular Languages Closure Properties – REGEX Construction: We claim the REGEX E = E1.E2

accepts L1.L2, i.e. L(E1.E2) = L(E1).L(E2). – Proof of correctness: trivial by definition of regular expressions.

– L1.L2 is regular since there is a REGEX E1.E2 accepting this language.

Closure under Concatenation

Lemma The class of regular languages is closed under concatenation.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1.L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2.

Ashutosh Trivedi – 7 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Proof of correctness: trivial by definition of regular expressions.

– L1.L2 is regular since there is a REGEX E1.E2 accepting this language.

Closure under Concatenation

Lemma The class of regular languages is closed under concatenation.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1.L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1.E2

accepts L1.L2, i.e. L(E1.E2) = L(E1).L(E2).

Ashutosh Trivedi – 7 of 13 Ashutosh Trivedi Regular Languages Closure Properties – L1.L2 is regular since there is a REGEX E1.E2 accepting this language.

Closure under Concatenation

Lemma The class of regular languages is closed under concatenation.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1.L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1.E2

accepts L1.L2, i.e. L(E1.E2) = L(E1).L(E2). – Proof of correctness: trivial by definition of regular expressions.

Ashutosh Trivedi – 7 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Concatenation

Lemma The class of regular languages is closed under concatenation.

Proof.

– Prove for arbitrary regular languages L1 and L2 that L1.L2 is a regular languages.

– Let E1 and E2 be REGEX accepting L1 and L2. – REGEX Construction: We claim the REGEX E = E1.E2

accepts L1.L2, i.e. L(E1.E2) = L(E1).L(E2). – Proof of correctness: trivial by definition of regular expressions.

– L1.L2 is regular since there is a REGEX E1.E2 accepting this language.

Ashutosh Trivedi – 7 of 13 Ashutosh Trivedi Regular Languages Closure Properties – REGEX Construction: We claim the REGEX E0 = E∗ accepts L, i.e. L(E∗) = (L(E))∗. – Proof of correctness: trivial by definition of regular expressions. – L∗ is regular since there is a REGEX E∗ accepting this language.

Closure under Kleene Star Operation

Lemma The class of regular languages is closed under Kleene star operation.

Proof. – Prove for arbitrary regular language L that L∗ is a regular languages. – Let E be REGEX accepting L.

Ashutosh Trivedi – 8 of 13 Ashutosh Trivedi Regular Languages Closure Properties – Proof of correctness: trivial by definition of regular expressions. – L∗ is regular since there is a REGEX E∗ accepting this language.

Closure under Kleene Star Operation

Lemma The class of regular languages is closed under Kleene star operation.

Proof. – Prove for arbitrary regular language L that L∗ is a regular languages. – Let E be REGEX accepting L. – REGEX Construction: We claim the REGEX E0 = E∗ accepts L, i.e. L(E∗) = (L(E))∗.

Ashutosh Trivedi – 8 of 13 Ashutosh Trivedi Regular Languages Closure Properties – L∗ is regular since there is a REGEX E∗ accepting this language.

Closure under Kleene Star Operation

Lemma The class of regular languages is closed under Kleene star operation.

Proof. – Prove for arbitrary regular language L that L∗ is a regular languages. – Let E be REGEX accepting L. – REGEX Construction: We claim the REGEX E0 = E∗ accepts L, i.e. L(E∗) = (L(E))∗. – Proof of correctness: trivial by definition of regular expressions.

Ashutosh Trivedi – 8 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Kleene Star Operation

Lemma The class of regular languages is closed under Kleene star operation.

Proof. – Prove for arbitrary regular language L that L∗ is a regular languages. – Let E be REGEX accepting L. – REGEX Construction: We claim the REGEX E0 = E∗ accepts L, i.e. L(E∗) = (L(E))∗. – Proof of correctness: trivial by definition of regular expressions. – L∗ is regular since there is a REGEX E∗ accepting this language.

Ashutosh Trivedi – 8 of 13 Ashutosh Trivedi Regular Languages Closure Properties – can be extended from letters to strings hˆ :Σ∗ → Γ∗ in a straightforward manner: ( ε if w = ε hˆ(w) = hˆ(w).h(a) if w = xa

– We can apply homomorphism to languages as well, for a homomorphism h and a language L ⊆ Σ∗ we define h(L) ⊆ Γ∗ as h(L) = {hˆ(w) ∈ Γ∗ : w ∈ L ⊆ Σ∗}.

– We define inverse-homomorphism of a language L ∈ Γ∗ as h−1(L) = {w ∈ Σ∗ : hˆ(w) ∈ L ⊆ Γ∗}.

Theorem The class of regular languages is closed under homomorphism, and inverse-homomorphism.

Closure under Homomorphism

–A homomorphism is just substitution of strings for letters. – Formally a homomorphism is a function h :Σ → Γ∗.

Ashutosh Trivedi – 9 of 13 Ashutosh Trivedi Regular Languages Closure Properties – We can apply homomorphism to languages as well, for a homomorphism h and a language L ⊆ Σ∗ we define h(L) ⊆ Γ∗ as h(L) = {hˆ(w) ∈ Γ∗ : w ∈ L ⊆ Σ∗}.

– We define inverse-homomorphism of a language L ∈ Γ∗ as h−1(L) = {w ∈ Σ∗ : hˆ(w) ∈ L ⊆ Γ∗}.

Theorem The class of regular languages is closed under homomorphism, and inverse-homomorphism.

Closure under Homomorphism

–A homomorphism is just substitution of strings for letters. – Formally a homomorphism is a function h :Σ → Γ∗. – Homomorphism can be extended from letters to strings hˆ :Σ∗ → Γ∗ in a straightforward manner: ( ε if w = ε hˆ(w) = hˆ(w).h(a) if w = xa

Ashutosh Trivedi – 9 of 13 Ashutosh Trivedi Regular Languages Closure Properties – We define inverse-homomorphism of a language L ∈ Γ∗ as h−1(L) = {w ∈ Σ∗ : hˆ(w) ∈ L ⊆ Γ∗}.

Theorem The class of regular languages is closed under homomorphism, and inverse-homomorphism.

Closure under Homomorphism

–A homomorphism is just substitution of strings for letters. – Formally a homomorphism is a function h :Σ → Γ∗. – Homomorphism can be extended from letters to strings hˆ :Σ∗ → Γ∗ in a straightforward manner: ( ε if w = ε hˆ(w) = hˆ(w).h(a) if w = xa

– We can apply homomorphism to languages as well, for a homomorphism h and a language L ⊆ Σ∗ we define h(L) ⊆ Γ∗ as h(L) = {hˆ(w) ∈ Γ∗ : w ∈ L ⊆ Σ∗}.

Ashutosh Trivedi – 9 of 13 Ashutosh Trivedi Regular Languages Closure Properties Theorem The class of regular languages is closed under homomorphism, and inverse-homomorphism.

Closure under Homomorphism

–A homomorphism is just substitution of strings for letters. – Formally a homomorphism is a function h :Σ → Γ∗. – Homomorphism can be extended from letters to strings hˆ :Σ∗ → Γ∗ in a straightforward manner: ( ε if w = ε hˆ(w) = hˆ(w).h(a) if w = xa

– We can apply homomorphism to languages as well, for a homomorphism h and a language L ⊆ Σ∗ we define h(L) ⊆ Γ∗ as h(L) = {hˆ(w) ∈ Γ∗ : w ∈ L ⊆ Σ∗}.

– We define inverse-homomorphism of a language L ∈ Γ∗ as h−1(L) = {w ∈ Σ∗ : hˆ(w) ∈ L ⊆ Γ∗}.

Ashutosh Trivedi – 9 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Homomorphism

–A homomorphism is just substitution of strings for letters. – Formally a homomorphism is a function h :Σ → Γ∗. – Homomorphism can be extended from letters to strings hˆ :Σ∗ → Γ∗ in a straightforward manner: ( ε if w = ε hˆ(w) = hˆ(w).h(a) if w = xa

– We can apply homomorphism to languages as well, for a homomorphism h and a language L ⊆ Σ∗ we define h(L) ⊆ Γ∗ as h(L) = {hˆ(w) ∈ Γ∗ : w ∈ L ⊆ Σ∗}.

– We define inverse-homomorphism of a language L ∈ Γ∗ as h−1(L) = {w ∈ Σ∗ : hˆ(w) ∈ L ⊆ Γ∗}.

Theorem The class of regular languages is closed under homomorphism, and inverse-homomorphism. Ashutosh Trivedi – 9 of 13 Ashutosh Trivedi Regular Languages Closure Properties – REGEX Construction: We claim the REGEX Eh defined inductively as

Eh = ε if E = ε

Eh = ∅ if E = ∅

Eh = h(a) if E = a

Eh = Fh + Gh if E = F + G

Eh = Fh.Gh if E = F.G ∗ ∗ Eh = (Fh) if E = F

accepts h(L), i.e. L(Eh) = h(L(E)).

Closure under Homomorphism

Lemma The class of regular languages is closed under homomorphism.

Proof. – Prove for arbitrary regular language L and homomorphism h that h(L) is a regular languages. Let E be REGEX accepting L.

Ashutosh Trivedi – 10 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Homomorphism

Lemma The class of regular languages is closed under homomorphism.

Proof. – Prove for arbitrary regular language L and homomorphism h that h(L) is a regular languages. Let E be REGEX accepting L.

– REGEX Construction: We claim the REGEX Eh defined inductively as

Eh = ε if E = ε

Eh = ∅ if E = ∅

Eh = h(a) if E = a

Eh = Fh + Gh if E = F + G

Eh = Fh.Gh if E = F.G ∗ ∗ Eh = (Fh) if E = F

accepts h(L), i.e. L(Eh) = h(L(E)).

Ashutosh Trivedi – 10 of 13 Ashutosh Trivedi Regular Languages Closure Properties – if E = a, then

LHS = L(Eh) = L(h(a)) = {h(a)} RHS = h(L(E)) = h(L(a)) = h({a}) = {h(a)}.

– if E = F + G, then

L(h(E)) = L(h(F + G)) = L(h(F) + h(G)) = L(h(F)) ∪ L(h(G)) h(L(E)) = h(L(F + G)) = h(L(F)) ∪ h(L(G)).

From inductive hypothesis both of these expression are equal. – Other inductive cases are similar, and hence omitted.

Closure under Homomorphism

– Proof of correctness: Prove that L(Eh) = h(L(E)). – if E = ε, then

LHS = L(Eh) = L(h(ε)) = L(ε) = {ε} RHS = h(L(E)) = h(L(ε)) = h({ε}) = {ε}.

– Similarly for E = ∅.

Ashutosh Trivedi – 11 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Homomorphism

– Proof of correctness: Prove that L(Eh) = h(L(E)). – if E = ε, then

LHS = L(Eh) = L(h(ε)) = L(ε) = {ε} RHS = h(L(E)) = h(L(ε)) = h({ε}) = {ε}.

– Similarly for E = ∅. – if E = a, then

LHS = L(Eh) = L(h(a)) = {h(a)} RHS = h(L(E)) = h(L(a)) = h({a}) = {h(a)}.

– if E = F + G, then

L(h(E)) = L(h(F + G)) = L(h(F) + h(G)) = L(h(F)) ∪ L(h(G)) h(L(E)) = h(L(F + G)) = h(L(F)) ∪ h(L(G)).

From inductive hypothesis both of these expression are equal. – Other inductive cases are similar, and hence omitted.

Ashutosh Trivedi – 11 of 13 Ashutosh Trivedi Regular Languages Closure Properties Closure under Inverse-Homomorphism

Lemma The class of regular languages is closed under homomorphism.

Proof. ∗ Let A = (S, Γ, δ, s0, F) be a DFA accepting L and h :Σ → Γ be an arbitrary −1 0 0 0 0 homomorphism. We show that the DFA h (A) = (S , Σ, δ , s0, F ) defined below accepts h−1(L). 0 0 0 – S = S, s0 = s0, F = F – δ0(s, a) = δˆ(s, h(a)) It is an easy induction over w that δˆ0(s, w) = δˆ(s, h(w)). Now, since accepting states of A and h−1(A) are the same, h−1(A) accepts w iff A accepts h(w).

Ashutosh Trivedi – 12 of 13 Ashutosh Trivedi Regular Languages Closure Properties Practice Questions

1. Quotient Language. For a ∈ Σ and L ⊆ Σ∗ we define

L/a = {w : wa ∈ L}. a/L = {w : aw ∈ L}. L.a = {wa : w ∈ L}. a.L = {aw : w ∈ L}.

2. min(L) is the set of strings w such that w ∈ L and no proper prefix of w is in L. 3. max(L) is the set of strings such that w ∈ L and no proper extension wx ∈ L. 4. INIT(L) is the set of strings w such that for some x we have that wx ∈ L. 5. HALF(L) is the set of strings w such that for some string x of same size as w we have that wx ∈ L.

Ashutosh Trivedi – 13 of 13 Ashutosh Trivedi Regular Languages Closure Properties