Discrete Mathematics and Logic II. Regular Sets SFWR ENG 2FA3 Ryszard Janicki Winter 24 Acknowledgments: Material based on Automata and Computability by Dexter C. Kozen (Chapter 4). Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets / 2
Induction to prove that an automaton accepts a set Regular sets: A = {x {, } x represents a multiple of three in binary} r r r2 Does this automaton accept exactly the above set A? Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 2 / 2
Induction to prove that an automaton accepts a set Preliminaries for answering the question: #x denote the number represented by string x in binary The question can be formalised as follows: Show that for any string x in {, }, we have δ (r, x) = r i #x mod 3 δ (r, x) = r i #x mod 3 δ (r, x) = r 2 i #x 2 mod 3 Shortly δ (r, x) = r (#x mod 3) Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 3 / 2
Induction to prove that an automaton accepts a set Preliminaries for answering the question (continued): r r r2 We have #(xb) = 2(#x) + b for b a bit (i.e., or ) we see that for any state r q {r, r, r 2 } (i.e., q {,, 2}) and input symbol b {, }, we have δ (r q, b) = r ((2q+b) mod 3) Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 4 / 2
Induction to prove that an automaton accepts a set Answering the question: Use the inductive denition of δ to show δ (r, x) = r (#x mod 3) by induction on x Base case: δ (r, ɛ) = r (#ɛ mod 3) Induction step : δ (r, xb) = r (#xb mod 3) Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 5 / 2
Some Closure Properties of Regular Sets Motivation: Let A, B Σ such that A and B regular sets. are A B, A B, and A regular sets? Are AB and A also regular? Let f be an n-ary operation on S and T S. T is closed under f, if (t, t 2,, t n t, t 2,, t n T : f (t, t 2,, t n ) T ) Idea: From the automata that accept A and B, can we built automata that accept the above sets?!!!! We need to devise a way to combine automata Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 6 / 2
Some Closure Properties of Regular Sets (The Product Construction) If we assume that A and B are regular M = (Q, Σ, δ, s, F ) M 2 = (Q 2, Σ, δ 2, s 2, F 2 ) with A = L(M ) and B = L(M 2 ) To show that A B is regular, we will build an automaton M 3 such that L(M 3 ) = A B How does M 3 work (Intuitively)? Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 7 / 2
Some Closure Properties of Regular Sets (The Product Construction) Let M 3 = (Q 3, Σ, δ 3, s 3, F 3 ) where Q 3 = Q Q 2 = {(p, q) p Q q Q 2 } F 3 = F F 2 s 3 = (s, s 2 ) δ 3 : Q 3 Σ Q 3 dened by δ 3 ((p, q), a) = (δ (p, a), δ 2 (q, a)) The automaton M 3 is called the product of M and M 2 Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 8 / 2
Some Closure Properties of Regular Sets (The Product Construction) Lemma ( ( ) ) x x Σ : δ3 ((p, q), x) = δ (p, x), δ2 (q, x) Proof. By induction on x Base case: For x ( = ɛ, do we have ) δ 3 ((p, q), ɛ) = δ (p, ɛ), δ2 (q, ɛ)??? Induction step: Assuming the lemma holds for x Σ, can we show that it holds for xa, where a Σ??? Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 9 / 2
Some Closure Properties of Regular Sets (Closure under intersection) Theorem L(M 3 ) = L(M ) L(M 2 ) Proof. For all x Σ x L(M 3 ) Denition of acceptance δ 3 (s 3, x) F 3 Denition of s 3 and F 3 Lemma x L(M ) L(M 2 ) Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets / 2
Some Closure Properties of Regular Sets (Closure under complement) Regular sets: A = {x {, } x represents a multiple of three in binary} r r r2 A = {x {, } x DOES NOT represent a multiple of three in binary} r r r2 Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets / 2
Some Closure Properties of Regular Sets (Closure under union) We have showed that regular sets are closed under intersection and complement We have A B = ( A B ) Then regular sets are closed under We get an automaton for A B that looks exactly like the product automaton for A B, except that the accept states are F 3 = (F Q 2 ) (Q F 2 ) instead of F F 2 Ryszard Janicki Discrete Mathematics and Logic II. Regular Sets 2 / 2