Strings and Sets: A string over Σ is any nite-length sequence of elements of Σ The set of all strings over alphabet Σ is denoted as Σ Operators over set: set complement, union, intersection, etc. set concatenation AB, power of set A n, A, A +
Strings and Sets: A string over Σ is any nite-length sequence of elements of Σ The set of all strings over alphabet Σ is denoted as Σ Operators over set: set complement, union, intersection, etc. set concatenation AB, power of set A n, A, A + Right-linear grammars (regular grammar) can dene regular language
Strings and Sets: A string over Σ is any nite-length sequence of elements of Σ The set of all strings over alphabet Σ is denoted as Σ Operators over set: set complement, union, intersection, etc. set concatenation AB, power of set A n, A, A + Right-linear grammars (regular grammar) can dene regular language The set of all strings accepted by deterministic nite automaton (DFA) is denoted as A = L(M)
Strings and Sets: A string over Σ is any nite-length sequence of elements of Σ The set of all strings over alphabet Σ is denoted as Σ Operators over set: set complement, union, intersection, etc. set concatenation AB, power of set A n, A, A + Right-linear grammars (regular grammar) can dene regular language The set of all strings accepted by deterministic nite automaton (DFA) is denoted as A = L(M) Grammars and machine models are related: Chomsky hierarchy
Strings and Sets: A string over Σ is any nite-length sequence of elements of Σ The set of all strings over alphabet Σ is denoted as Σ Operators over set: set complement, union, intersection, etc. set concatenation AB, power of set A n, A, A + Right-linear grammars (regular grammar) can dene regular language The set of all strings accepted by deterministic nite automaton (DFA) is denoted as A = L(M) Grammars and machine models are related: Chomsky hierarchy right-linear grammars < > nite memory A subset A Σ is said to be a regular set if A = L(M) for some nite automaton M.
Finite Automata and Regular Sets Automata Finite We model these abstractly by a mathematical model called a finite automaton Definition (Deterministic finite automaton) Formally, a deterministic finite automaton (DFA) is a structure M = (Q, Σ, δ, s, F ), where Q is a finite set of states; Σ is a finite set called input alphabet; δ : Q Σ Q is the transition function s Q is the start state; F is a subset of Q ; elements of F are called accept or final states. SFWR ENG 2FA3: Discrete Mathematics and Logic II Dr. R. Khedri States and Transitions Finite Automata Representation of an automaton How a finite automaton operates? Language and regular set Dr. R. Khedri SFWR ENG 2FA3: Discrete Mathematics and Logic II
Question 1. Show that the following language is regular {awa w {a, b} }
Question 1. Show that the following language is regular {awa w {a, b} }
Question 1. Show that the following language is regular {awa w {a, b} }
Question 1. Show that the following language is regular {awa w {a, b} }
Question 1. Show that the following language is regular {awa w {a, b} } Since we have constructed a DFA for the language, we can claim that, by denition, the language is regular.
Some Closure Properties of Regular Sets Closure under intersection: A B Closure under complement: A Closure under union: A B = ( A B)
Some Closure Properties of Regular Sets Closure under intersection: A B Closure under complement: A Closure under union: A B = ( A B) Devise a way to construct new automaton intersection: the product construction
More on Regular Sets Some Closure Properties of Regular Sets (The Product Construction) Let M 3 = (Q 3, Σ, δ 3, s 3, F 3 ) where Q 3 = Q 1 Q 2 = {(p, q) p Q 1 q Q 2 } F 3 = F 1 F 2 s 3 = (s 1, s 2 ) δ 3 : Q 3 Σ Q 3 defined by SFWR ENG 2FA3: Discrete Mathematics and Logic II Dr. R. Khedri Induction to prove that an automaton accepts a set Some Closure Properties of Regular Sets The Product Construction Closure under intersection Closure under complement Closure under union δ 3 ((p, q), a) = (δ 1 (p, a), δ 2 (q, a)) The automaton M 3 is called the product of M 1 and M 2 Dr. R. Khedri SFWR ENG 2FA3: Discrete Mathematics and Logic II
Question 2. Use the product construction to come up with a deterministic nite automaton (DFA) that accepts all strings from {a, b} that contain an even number of a and that are formed by a repetition of the string ab (ie ababababab). Your report should explicitly give all the steps leading to the construction of the propsed DFA.
Question 2. Use the product construction to come up with a deterministic nite automaton (DFA) that accepts all strings from {a, b} that contain an even number of a and that are formed by a repetition of the string ab (ie ababababab). Your report should explicitly give all the steps leading to the construction of the propsed DFA. 1. L(M 1 ) = {x {a, b} x contains even number of a's}
Question 2. Use the product construction to come up with a deterministic nite automaton (DFA) that accepts all strings from {a, b} that contain an even number of a and that are formed by a repetition of the string ab (ie ababababab). Your report should explicitly give all the steps leading to the construction of the propsed DFA. 1. L(M 1 ) = {x {a, b} x contains even number of a's} 2. L(M 2 ) = {x {a, b} x is formed by repetition of ab}
Question 2. Use the product construction to come up with a deterministic nite automaton (DFA) that accepts all strings from {a, b} that contain an even number of a and that are formed by a repetition of the string ab (ie ababababab). Your report should explicitly give all the steps leading to the construction of the propsed DFA. 1. L(M 1 ) = {x {a, b} x contains even number of a's} 2. L(M 2 ) = {x {a, b} x is formed by repetition of ab} 3. L(M 3 ) = L(M 1 ) L(M 2 ): Product construct
1. L(M 1 ) = {x {a, b} x contains even number of a's} 1. Q 1 = {e, o} 2. = {a, b} 3. S 1 = e 4. F 1 = {e} 5. δ 1 can be given as table: a b e o e o e o
1. L(M 1 ) = {x {a, b} x contains even number of a's} 1. Q 1 = {e, o} 2. = {a, b} 3. S 1 = e 4. F 1 = {e} 5. δ 1 can be given as table: a b e o e o e o
2. L(M 2 ) = {x {a, b} x is formed by repetition of ab}
2. L(M 2 ) = {x {a, b} x is formed by repetition of ab}
2. L(M 2 ) = {x {a, b} x is formed by repetition of ab}
2. L(M 2 ) = {x {a, b} x is formed by repetition of ab} 1. Q 2 = {q 0, q 1, q 2 } 2. Σ = {a, b} 3. s 2 = q 0 4. F 2 = {q 0 } a b 5. δ 2 can be given as following table: q 0 q 1 q 2 q 1 q 2 q 0 q 2 q 2 q 2
3. L(M 3 ) = L(M 1 ) L(M 2 ): Product construct Product construction: 1. Q 3 = {e, o} {q 0, q 1, q 2 } = {(e, q 0 ), (e, q 1 ), (e, q 3 ), (o, q 0 ), (o, q 1 ), (o, q 2 ), } 2. Σ = {a, b} 3. s 3 = (s 1, s 2 ) = (e, q 0 ) 4. F 3 = F 1 F 2 = {e} {q 0 } = {(e, q 0 )} 5. δ 3 is given as the following table: a b (e, q 0 ) (o, q 1 ) (e, q 2 ) (e, q 1 ) (o, q 2 ) (e, q 0 ) (e, q 3 ) (o, q 2 ) (e, q 2 ) (o, q 0 ) (e, q 1 ) (o, q 2 ) (o, q 1 ) (e, q 2 ) (o, q 0 ) (o, q 2 ) (e, q 2 ) (o, q 2 ) a b e o e o e o a b q 0 q 1 q 2 q 1 q 2 q 0 q 2 q 2 q 2
3. L(M 3 ) = L(M 1 ) L(M 2 ): Product construct
Some Closure Properties of Regular Sets Closure under intersection: A B Closure under complement: A Closure under union: A B = ( A B) Devise a way to construct new automaton intersection: the product construction complement: reverse accept and reject states
Question 3. Construct a nite automaton that accepts all binary strings without 111 as substring. 1. L(M ) = {x {0, 1} x accepts all binary strings with 111 as a substring}
Question 3. Construct a nite automaton that accepts all binary strings without 111 as substring. 1. L(M ) = {x {0, 1} x accepts all binary strings with 111 as a substring} 2. L(M) = L(M ): reverse accpet and reject states
1. L(M ) = {x {0, 1} x accepts all binary strings with 111 as a substring}
1. L(M ) = {x {0, 1} x accepts all binary strings with 111 as a substring}
2. L(M) = L(M ): reverse accpet and reject states
Exercise: Show that L 2 = {aw 1 aaw 2 a : w 1, w 2 {a, b} } is regular.