A Derivative-Based Construction of an Alternating Automaton from a Regular Expression
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression P. Caron, J.-M. Champarnaud and L. Mignot ´ Universite´ de Rouen, LITIS, Equipe Combinatoire et Algorithmes
09/13/2012
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
1 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Sommaire
1
(Alternating) Automata
2
Derivative-Based Construction Methods
3
Alternating Automaton Computation
4
Conclusion
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
2 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
1
(Alternating) Automata
2
Derivative-Based Construction Methods
3
Alternating Automaton Computation
4
Conclusion
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
3 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Automata
Abstract Definition An automaton is a 5-tuple (Σ, Q, I, F , δ) where: Σ is the alphabet, Q is the set of states.
Conditions over I, F and δ define the type of the automaton.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
4 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Deterministic Automata
Definition A deterministic automaton is an automaton (Σ, Q, I, F , δ) where: I is the initial state, F ⊂ Q is the set of the final states, δ is a function from Q × Σ to Q.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
5 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Nondeterministic Automata
Definition A nondeterministic automaton is an automaton (Σ, Q, I, F , δ) where: I ⊂ Q is the set of initial states, F ⊂ Q is the set of the final states, δ is a function from Q × Σ to 2Q .
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
6 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automata
Definition An alternating automaton is an automaton (Σ, Q, I, F , δ) where: I is a boolean formula over Q, F is a function from Q to {0, 1}, δ is a function from Q × Σ to BoolForm(Q), the set of boolean formulae over Q.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
7 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automaton Example Example Σ = {a, b}, Q = {q1 , q2 , q3 }, I = q1 ∧ (q2 XOR q3 ), HH Q HH q1 q2 q3 Σ 1 if q = q3 , H H F (q) = , a q2 ∨ q3 ¬ q3 ⊥ 0 otherwise, b q2 → q3 q1 ∧ q3 ¬⊥
Is ab recognized ? a
I = q1 ∧ (q2 XOR q3 ) −−−−−→ (q2 ∨ q3 ) ∧ ((¬ q3 ) XOR ⊥)
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
8 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automaton Example Example Σ = {a, b}, Q = {q1 , q2 , q3 }, I = q1 ∧ (q2 XOR q3 ), H HH Q q1 q2 q3 Σ HH 1 if q = q3 , H F (q) = , 0 otherwise, a q2 ∨ q3 ¬ q3 ⊥ b q2 → q3 q1 ∧ q3 ¬⊥
Is ab recognized ? b
(q2 ∨ q3 ) ∧ ((¬q3 ) XOR ⊥) −−→ ((q1 ∧ q3 ) ∨ (¬⊥)) ∧ ((¬(¬⊥)) XOR ⊥)
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
9 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automaton Example Example Σ = {a, b}, Q = {q1 , q2 , q3 }, I = q1 ∧ (q2 XOR q3 ), HH Q H q1 q2 q3 Σ HH 1 if q = q3 , H F (q) = , 0 otherwise, a q2 ∨ q3 ¬ q3 ⊥ b q2 → q3 q1 ∧ q3 ¬⊥ Is ab recognized ? F ((q1 ∧ q3 ) ∨ (¬⊥)) ∧ ((¬(¬⊥)) XOR ⊥) = ((0 ∧ 1) ∨ (¬0)) ∧ ((¬(¬0)) XOR 0) P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
10 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automaton Example Example Σ = {a, b}, Q = {q1 , q2 , q3 }, I = q1 ∧ (q2 XOR q3 ), HH Q H q1 q2 q3 Σ HH 1 if q = q3 , H F (q) = , 0 otherwise, a q2 ∨ q3 ¬ q3 ⊥ b q2 → q3 q1 ∧ q3 ¬⊥ Is ab recognized ? ((0 ∧ 1) ∨ (¬0)) ∧ ((¬(¬0)) XOR 0) = ((0 ∧ 1) ∨ (¬0)) ∧ 0 P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
11 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression (Alternating) Automata
Alternating Automaton Example Example Σ = {a, b}, Q = {q1 , q2 , q3 }, I = q1 ∧ (q2 XOR q3 ), H HH Q q1 q2 q3 Σ HH 1 if q = q3 , H F (q) = , 0 otherwise, a q2 ∨ q3 ¬ q3 ⊥ b q2 → q3 q1 ∧ q3 ¬⊥ Is ab recognized ? ((0 ∧ 1) ∨ (¬0)) ∧ 0 = 0 P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
12 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Derivative-Based Construction Methods
1
(Alternating) Automata
2
Derivative-Based Construction Methods
3
Alternating Automaton Computation
4
Conclusion
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
13 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Derivative-Based Construction Methods
Regular Expression Definition A regular expression E over an alphabet Σ is inductively defined by: E = a, E = 0, E = 1 E = E1 · E2 , E = E1∗ , E = f (E1 , . . . , Ek ), where: a is any symbol in Σ, E1 , . . . , Ek are any k regular expressions over Σ, f is a k-ary boolean operator.
If the only boolean operator that appears is +, E is said to be a simple regular expression. P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
14 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Derivative-Based Construction Methods
Brzozowski Derivatives
Derivatives Properties A derivative of a regular expression w.r.t. a symbol is a regular expression. Derivatives computation can be used to solve the membership problem without computing an automaton. Derivatives computation can be used to construct a deterministic automaton with an ACI-test.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
15 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Derivative-Based Construction Methods
Antimirov Partial Derivatives
Partial Derivatives Properties A partial derivative of a simple regular expression w.r.t. a symbol is a set of regular expressions. Partial derivatives computation can be used to solve the membership problem without computing an automaton. Partial derivatives computation can be used to construct a nondeterministic automaton without an ACI-test.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
16 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Derivative-Based Construction Methods
Alternating Automata Computation
Derivatives for Alternating Automata ? How can a boolean formula be computed from a regular expression using a structure handling an ACI-test ? =⇒ Disjunctive Clausal Forms to compute derivatives.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
17 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
1
(Alternating) Automata
2
Derivative-Based Construction Methods
3
Alternating Automaton Computation
4
Conclusion
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
18 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Disjunctive Clausal Forms of Regular Expressions Definition A Disjunctive Clausal Form of regular expressions is a set of literal sets. A literal is: either a regular expression (positive literal) or an over-lined regular expression (negative literal).
L({{a∗ b, b∗ }, {a∗ }}) = (L(a∗ b) ∩ ¬(L(b∗ ))) ∪ L(a∗ ) P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
19 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Operations over Clausal Forms Notations A sum: C1 ⊕ C2 A conjunction: C1 ⊗ C2 A negation: C1 A catenation product: C1 E Proposition To any boolean operator f can be associated a clausal operator f 0 constructed with ⊕, ⊗ and operators and such that L(f (E1 , . . . , Ek )) = L(f 0 ({{E1 }}, . . . , {{Ek }})) E1 XORE2 ⇐⇒ ( ({{E1 }}) ⊗ {{E2 }}) ⊕ ( ({{E2 }}) ⊗ {{E1 }}) P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
20 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Clausal Derivation Formulae Definition The clausal derivative of a regular expression E w.r.t. a symbol a is the disjunctive clausal form D(a, E) inductively defined as follows: D(a, a) = {{1}}, D(a, b) = D(a, 1) = D(a, 0) = ∅, D(a, E1 · E2 ) =
(D(a, E1 ) E2 ) ⊕ D(a, E2 ) if 1 ∈ L(E1 ), D(a, E1 ) E2 otherwise,
D(a, E1∗ ) = D(a, E1 ) E1∗ , D(a, f (E1 , . . . , Ek )) = f 0 (D(a, E1 ), . . . , D(a, Ek )). P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
21 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Derivation Example Let E = ((ab)∗ a)XOR((abab)∗ a). D(a, E) = (D(a, (ab)∗ a)) XOR (D(a, (abab)∗ a)) = ( (D(a, (ab)∗ a)) ⊗ D(a, (abab)∗ a)) ⊕(D(a, (ab)∗ a) ⊗ (D(a, (abab)∗ a))) = ( ({{b(ab)∗ a}, {1}}) ⊗ {{bab(abab)∗ a}, {1}}) ⊕({{b(ab)∗ a}, {1}} ⊗ ({{bab(abab)∗ a}, {1}})) = ({{b(ab)∗ a, 1}} ⊗ {{bab(abab)∗ a}, {1}}) ⊕({{b(ab)∗ a}, {1}} ⊗ {{bab(abab)∗ a, 1}}) = {{b(ab)∗ a, 1, bab(abab)∗ a}, {b(ab)∗ a, 1, 1}, {b(ab)∗ a, bab(abab)∗ a, 1}, {1, bab(abab)∗ a, 1}}
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
22 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Derivation Example D(b, E) =∅ D(a, b(ab)∗ a) =∅ = {{(ab)∗ a}} D(b, b(ab)∗ a) D(a, (ab)∗ a) = {{b(ab)∗ a}, {1}} ∗ D(b, (ab) a) =∅ D(a, 1) =∅ D(b, 1) =∅ D(a, bab(abab)∗ a)= ∅ D(b, bab(abab)∗ a)= {{ab(abab)∗ a}} D(a, ab(abab)∗ a) = {{b(abab)∗ a}} D(b, ab(abab)∗ a) = ∅ D(a, b(abab)∗ a) = ∅ D(b, b(abab)∗ a) = {{(abab)∗ a}} D(a, (abab)∗ a) = {{bab(abab)∗ a}, {1}} ∗ D(b, (abab) a) =∅ P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
23 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Derivation Example From the computation of the derivatives, we deduce: the set Q = {q1 , . . . , q8 } of states : q1 = E, q2 = b(ab)∗ a, q3 = 1, q4 = bab(abab)∗ a, q5 = ab(abab)∗ a, q6 = b(abab)∗ a, q7 = (ab)∗ a, q8 = (abab)∗ a, the function F from Q to B: 1 if q = q3 , F (q) = 0 otherwise.
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
24 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Alternating Automaton Computation
Derivation Example From the computation of the derivatives, we deduce: and the function δ from Q × Σ to BoolForm(Q):
a
b
q1 ¬q2 ∧ ¬q3 ∧ q4 ∨ ¬q2 ∧ ¬q3 ∧ q3 ∨ q2 ∧ ¬q4 ∧ ¬q3 ∨ q3 ∧ ¬q4 ∧ ¬q3 0
P. Caron et al. (Universite´ de Rouen, LITIS)
q2
q3
q4
q5
q6
q7
q8
0
0
0
q6
0
q2 ∨ q3
q4 ∨ q3
q7
0
q5
0
q8
0
0
Regular Expression to Alternating Automaton
09/13/2012
25 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Conclusion
1
(Alternating) Automata
2
Derivative-Based Construction Methods
3
Alternating Automaton Computation
4
Conclusion
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
26 / 27
A Derivative-Based Construction of an Alternating Automaton from a Regular Expression Conclusion
Conclusion and Perspectives
Computation of an Alternating Automaton from a regular expression using derivatives.
Other structures to handle derivatives ?
Time and space complexities ?
P. Caron et al. (Universite´ de Rouen, LITIS)
Regular Expression to Alternating Automaton
09/13/2012
27 / 27