lot of areas in computer science • Two fundamental problems: definition and recognition • We will see two different and equivalent ways of defining a pattern (for us, a set of strings) • Finite automata • Regular expressions
automata: each symbol is contained in 1 transition • Nondeterministic automata allow to have nondeterministic transitions • Acceptance of an input string asks only for at least one path labeled with it leading to an accepting state • We can convert one into another, preserving the accepted language (i.e. automata are equivalence)
automata: each symbol is contained in 1 transition • Nondeterministic automata allow to have nondeterministic transitions • Acceptance of an input string asks only for at least one path labeled with it leading to an accepting state • We can convert one into another, preserving the accepted language (i.e. automata are equivalence)
nondeterministic • We can convert a nondeterm. N into a determ. D using the subset construction • The states in D are subsets of states in N • Start state of D is {s0 }, being s0 start state of N • For each state S in D, we consider each input symbol x in turn. • There is a transition S->T in D, whose label includes x, for a state T, set of states t in N, if for some s in S there is a transition s->t including x in label • A state in D is accepting if contains at least one accepting state in N
epsilon-transitions 1. From a regular expression to an automaton with epsilon- transitions, accepting the same language 2. From an automaton with epsilon-transitions to an automaton without epsilon-transitions, accepting the same language
to an automaton with epsilon- transitions, accepting the same language Algorithm derived from a complete induction on the number of operator occurrences in the regular expression • Basis: n=0, i.e. R an atomic operand
to an automaton with epsilon- transitions, accepting the same language Algorithm derived from a complete induction on the number of operator occurrences in the regular expression • Induction: Case R = R1 | R2
to an automaton with epsilon- transitions, accepting the same language Algorithm derived from a complete induction on the number of operator occurrences in the regular expression • Induction: Case R = R1 R2
to an automaton with epsilon- transitions, accepting the same language Algorithm derived from a complete induction on the number of operator occurrences in the regular expression • Induction: Case R = R1 *
epsilon-transitions to an automaton without epsilon-transitions, accepting the same language • Reachability of states by paths with epsilon-transitions, in particular, for accepting states • New automaton bundles in one transition: a path with epsilon-transitions and a transition to an important state both from the old automaton.
epsilon-transitions to an automaton without epsilon-transitions, accepting the same language • Reachability of states by paths with epsilon-transitions, in particular, for accepting states • New automaton bundles in one transition: a path with epsilon-transitions and a transition to an important state both from the old automaton.
epsilon-transitions to an automaton without epsilon-transitions, accepting the same language • Reachability of states by paths with epsilon-transitions, in particular, for accepting states • New automaton bundles in one transition: a path with epsilon-transitions and a transition to an important state both from the old automaton.
epsilon-transitions to an automaton without epsilon-transitions, accepting the same language • Reachability of states by paths with epsilon-transitions, in particular, for accepting states • New automaton bundles in one transition: a path with epsilon-transitions and a transition to an important state both from the old automaton.
epsilon-transitions to an automaton without epsilon-transitions, accepting the same language • Reachability of states by paths with epsilon-transitions, in particular, for accepting states • New automaton bundles in one transition: a path with epsilon-transitions and a transition to an important state both from the old automaton.
epsilon-transitions A to an automaton without epsilon- transitions B, accepting the same language • Define the set of important states S as the set of states of B • Add to B a transition from states i to j (both in S) with label x if, in A, for some state k • k reachable from i by a path with epsilon-transitions • there is a transition from k to j with label x • Make an i in S an accepting state if, in A, from i an accepting is reachable by epsilon-trs.
epsilon-transitions A to an automaton without epsilon- transitions B, accepting the same language • Define the set of important states S as the set of states of B • Add to B a transition from states i to j (both in S) with label x if, in A, for some state k • k reachable from i by a path with epsilon-transitions • there is a transition from k to j with label x • Make an i in S an accepting state if, in A, from i an accepting is reachable by epsilon-trs.
states from an automaton • Use union on each arc, and concatenation along a path State-Elimination Construction • Add possibly • Add possibly • Replace U, U = Ø Rij, Rij = Ø Rij := Rij | SiU⇤Tj
automaton • For each accepting state , with starting state • Remove from (a copy of the original) automaton states until only and remain. Take the expr. • Take the union of the exprs. for each accepting state t 2 A s 6= t =) Rs,t = S⇤U(T | V S⇤U)⇤ s = t =) Rs,t = S⇤ s t s Rs,t