CSE 322 Exam Reviews Basic Concepts Formal Languages - PowerPoint PPT Presentation
CSE 322 Exam Reviews Basic Concepts Formal Languages Language/String Operations Alphabet ( ! ) String ( ! *) Regular Operations: Union ( $ ) Length (|x|) Concatenation ( ) Empty String ( " )
CSE 322 Exam Reviews
Basic Concepts • Formal Languages • Language/String Operations – Alphabet ( ! ) – String ( ! *) – “Regular” Operations: • Union ( $ ) – Length (|x|) • Concatenation ( • ) – Empty String ( " ) • (Kleene) Star (*) – Empty Language ( # ) – Other: • Intersection • Complement • Reversal • Shuffle • ...
Finite Defns of Infinite Languages • English, mathematical • Nondeterminism • DFAs • NFAs – States – Transitions ( % relation) – Start states • Missing out-edges – Accept states • Multiple out-edges – Transitions ( % function) • " -moves – M accepts w & ! * – N accepts w & ! * – M recognizes L ' ! * – N recognizes L ' ! * • Regular Expressions – # , " , a & ! , $ , • , * , ( ) • GNFAs
Key Results, Constructions, Methods • L is regular iff it is: • The class of regular languages is closed – Recognized by a DFA under: – Recognized by a NFA – Recognized by a GNFA – Regular ops: union, concatenation, star – Defined by a Regular Expr – Also: intersection, Proofs: complementation, GNFA ( Reg Expr (& reversal, prefix, (Kleene/Floyd/Warshall: R ik R kk * R kj ) no-prefix, … ) • NOT closed under ⊆ , ⊇ Reg Expr ( NFA (join NFAs w/ " -moves) • Also: Cross-product NFA ( DFA construction (union, …) (subset construction)
Applications • “globbing” • Compilers: – Id ::= letter ( letter|digit )* – lpr *.txt – Int ::= digit digit* • pattern-match – Float ::= searching: d d* . d* ( " | E d d* ) – (but not, e.g. expressions – grep “Ruzzo.*terrific” *.txt with nested, balanced parens, or variable names matched to declarations) • Finite state models of circuits, control systems, network protocols, API’s, etc., etc.
Non-Regular Languages • Key idea: once M is in • Cor: Pumping Lemma some state q, it doesn’t • Important examples: remember how it got L 1 = { a n b n | n >0 } there. L 2 = { w | # a (w) = # b (w) } E.g. “hybrids”: L 3 = { ww | w &! * } if xy & L(M) and L 4 = { ww R | w &! * } x, x’ both go to q, then L 5 = { balanced parens } x’y & L(M) too. • Also: closure under * , complementation E.g. “loops”: if xyz & L(M) and sometimes useful: x, xy both go to q, then – L 1 = L 2 * a*b* xy i z & L(M) for all i ) 0. • PS: don’t say “Irregular”
Context-Free Grammars • Terminals, Variables/Non-Terminals • Start Symbol S • Rules ( • Derivations + , + * • Left/right-most derivations • Derivation trees/parse trees • Ambiguity, Inherent ambiguity • A key feature: recursion/nesting/matching, e.g. S ( (S)S | "
Pushdown Automata • States, Start state, Final states, stack • Terminals ( ! ), Stack alphabet ( , ) • Configurations, Moves, |--, |--*, push/pop
Main Results • Every regular language is a CFL • Closure: union, dot, *, (Reversal; ! w/ Reg) • Non-Closure: Intersection, complementation • Equivalence of CFG & PDA – CFG ' PDA : top-down(match/expand), bottom-up (shift/reduce) – PDA ' CFG: A pq • Pumping Lemma & non-CFL’s • Deterministic PDA != Nondeterministic PDA
Important Examples • Some Context-Free Languages: – { a n b n | n > 0 } – { w | # a (w) = # b (w) } – { ww R | w & {a,b}* } – balanced parentheses – "C", Java, etc. • Some Non-Context-Free Languages: – { a n b n c n | n > 0 } Curiously, their – { w | # a (w) = # b (w) = # c (w) } complements are CFL’s – { ww | w & {a,b}* } – "C", Java, etc.
Applications • Programming languages and compilers • Parsing other complex input languages – html, sql, … • Natural language processing/ Computational linguistics – Requires handling ambiguous grammars • Computational biology (RNA)
The big picture Ability to specifiy and reason about abstract formal models of computational systems is an important life skill. Practice it.
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.