80 likes | 160 Views
Regular expressions. Sipser 1.3 (pages 63-76). Looks familiar…. Your turn now!. Formally. Definition 1.52: Say that R is a regular expression if R is a for some a in the alphabet Σ ε Ø ( R 1 ∪ R 2 ), where R 1 and R 2 are regular exressions
E N D
Regular expressions Sipser 1.3 (pages 63-76)
Formally • Definition 1.52: Say that R is a regular expression if R is • a for some a in the alphabet Σ • ε • Ø • (R1∪R2), where R1 and R2 are regular exressions • (R1°R2), where R1 and R2 are regular expressions • (R1*), where R1is a regular expression
Examples • 0*10* ={w | } • ={w | w is a string of odd length} • (0 ∪ ε)(1 ∪ ε) = • (01)*∅ = • (+ ∪ - ∪ ε)(DD* ∪ DD*.D* ∪ D*.DD*) = where D = {0,1,2,3,4,5,6,7,8,9}
Identities • Let R be a regular expression • R°Ø = • R°ε = • R∪Ø = • R∪ε =
Regular expressions and NFAs • Theorem 1.54: A language is regular if and only if some regular expression describes it. • Proof (⇐) • If a ∈ Σ, then a is regular. • ε is regular. • Ø is regular. • If R1 and R2 are regular, then (R1∪R2) is regular. • If R1 and R2 are regular, then (R1°R2) is regular. • If R1 is a regular, then (R1*) is regular
Proof in action • Build an NFA to that recognizes the regular expression a(a∪b)*a