DFA hyper-minimisation l Gawrychowski 1 Artur Je z 1 Pawe Institute - - PowerPoint PPT Presentation

dfa hyper minimisation
SMART_READER_LITE
LIVE PREVIEW

DFA hyper-minimisation l Gawrychowski 1 Artur Je z 1 Pawe Institute - - PowerPoint PPT Presentation

DFA hyper-minimisation l Gawrychowski 1 Artur Je z 1 Pawe Institute of Computer Science, University of Wroc law November 24, 2009 Artur Je z (UWr) DFA hyper-minimisation November 24, 2009 1 / 13 DFA minimisation Definition DFA:


slide-1
SLIDE 1

DFA hyper-minimisation

Pawe l Gawrychowski 1 Artur Je˙ z 1

Institute of Computer Science, University of Wroc law

November 24, 2009

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 1 / 13

slide-2
SLIDE 2

DFA minimisation

Definition

DFA: Q, Σ, δ, q0, F, where δ : Q × Σ → Q. DFA is minimal, if it has the minimal number of states among automata recognising L(M).

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 2 / 13

slide-3
SLIDE 3

DFA minimisation

Definition

DFA: Q, Σ, δ, q0, F, where δ : Q × Σ → Q. DFA is minimal, if it has the minimal number of states among automata recognising L(M). unique with this property calculated using ≡L: w ≡ w′ if and only if ∀w′′ ww ′′ ∈ L ⇐ ⇒ w′w′′ ∈ L equivalence classes correspond to

◮ states of the minimal automaton ◮ partition of states of M Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 2 / 13

slide-4
SLIDE 4

DFA minimisation

Definition

DFA: Q, Σ, δ, q0, F, where δ : Q × Σ → Q. DFA is minimal, if it has the minimal number of states among automata recognising L(M). unique with this property calculated using ≡L: w ≡ w′ if and only if ∀w′′ ww ′′ ∈ L ⇐ ⇒ w′w′′ ∈ L equivalence classes correspond to

◮ states of the minimal automaton ◮ partition of states of M

Hopcroft’s algorithm: O(n log n); refines the partition of states

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 2 / 13

slide-5
SLIDE 5

f -equivalence and hyper-minimisation

Definition (f -equivalent)

L∼L′ ⇐ ⇒ they differ on finite amount of words. Extend the definition to automata.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 3 / 13

slide-6
SLIDE 6

f -equivalence and hyper-minimisation

Definition (f -equivalent)

L∼L′ ⇐ ⇒ they differ on finite amount of words. Extend the definition to automata.

Definition (A. Badr, V. Geffert, I. Shipman)

M is hyper-minimal, if it has the minimal number of states among the f -equivalent automata.(Not unique)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 3 / 13

slide-7
SLIDE 7

f -equivalence and hyper-minimisation

Definition (f -equivalent)

L∼L′ ⇐ ⇒ they differ on finite amount of words. Extend the definition to automata.

Definition (A. Badr, V. Geffert, I. Shipman)

M is hyper-minimal, if it has the minimal number of states among the f -equivalent automata.(Not unique)

Remark

For fixed L we extend ∼ to words: w∼w′ ⇐ ⇒ w−1L∼w′−1L For fixed automata M we extend ∼ to states: q∼q′ ⇐ ⇒ L(q)∼L(q′) (where L(q) is the language recognised starting from q).

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 3 / 13

slide-8
SLIDE 8

Approach

Idea

We want a relation on words, such that equivalence classes are states of a hyper-minimal automaton, ∼ is a natural candidate.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 4 / 13

slide-9
SLIDE 9

Approach

Idea

We want a relation on words, such that equivalence classes are states of a hyper-minimal automaton, ∼ is a natural candidate. Classes of ∼ are groups of classes of ≡. We cannot greedily merge those groups: w : δ(q0, w) = q1: wL(q1) changes to wL(q3) = wL(q1). Infinitely many such w — problem!

L(q1) L(q2) = ⇒ L(q3) L(q1) ∼ L(q2) L(q1) ≡ L(q2)

No problem occurs if there are only finitely many such w.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 4 / 13

slide-10
SLIDE 10

Approach

Idea

We want a relation on words, such that equivalence classes are states of a hyper-minimal automaton, ∼ is a natural candidate. Classes of ∼ are groups of classes of ≡. We cannot greedily merge those groups: w : δ(q0, w) = q1: wL(q1) changes to wL(q3) = wL(q1). Infinitely many such w — problem!

L(q1) L(q2) = ⇒ L(q3) L(q1) ∼ L(q2) L(q1) ≡ L(q2)

No problem occurs if there are only finitely many such w.

Definition

State q is in preamble if {w : δ(q0, w) = q} is finite. In kernel otherwise.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 4 / 13

slide-11
SLIDE 11

Heuristic

Definition (state merging)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 5 / 13

slide-12
SLIDE 12

Heuristic

Definition (state merging) Heuristic

Greedily merge q to p whenever q ≡ p or q∼p and q is in the preamble

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 5 / 13

slide-13
SLIDE 13

Heuristic

Definition (state merging) Heuristic

Greedily merge q to p whenever q ≡ p or q∼p and q is in the preamble and there is no path from p to q

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 5 / 13

slide-14
SLIDE 14

Heuristic

Definition (state merging) Heuristic

Greedily merge q to p whenever q ≡ p or q∼p and q is in the preamble and there is no path from p to q

Theorem (A. Badr, V. Geffert, I. Shipman)

The heuristic is proper, i.e. it results in hyper-minimal automaton f -equivalent to the input one.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 5 / 13

slide-15
SLIDE 15

Data structures

Definition (Operational definition of ∼)

DM(q, q′) if q = q′ or, DM(q, q′) if for all a ∈ Σ DM δM(q, a), δM(q′, a)

  • .

Lemma

If the automaton M is minimised the D coincides with ∼.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 6 / 13

slide-16
SLIDE 16

Data structures

Definition (Operational definition of ∼)

DM(q, q′) if q = q′ or, DM(q, q′) if for all a ∈ Σ DM δM(q, a), δM(q′, a)

  • .

Lemma

If the automaton M is minimised the D coincides with ∼. We need a dictionary structure supporting query, if there are q, q′ such that (δ(q, 0), δ(q, 1)) = (δ(q′, 0), δ(q′, 1)) when q is merged to q′, fast update of δ

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 6 / 13

slide-17
SLIDE 17

Data structures

Definition (Operational definition of ∼)

DM(q, q′) if q = q′ or, DM(q, q′) if for all a ∈ Σ DM δM(q, a), δM(q′, a)

  • .

Lemma

If the automaton M is minimised the D coincides with ∼. We need a dictionary structure supporting query, if there are q, q′ such that (δ(q, 0), δ(q, 1)) = (δ(q′, 0), δ(q′, 1)) when q is merged to q′, fast update of δ Deterministic — tree: the path from root to the leave is (δ(q, 0), δ(q, 1)) Randomised — hashing

q1 q0 q δ(q, i) = qi

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 6 / 13

slide-18
SLIDE 18

Algorithm

Calculating relation D over states identify q, q′ with the same successors delete the one with less predecessors update the predecessors Using D greedily merge states.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 7 / 13

slide-19
SLIDE 19

Algorithm

Calculating relation D over states identify q, q′ with the same successors delete the one with less predecessors update the predecessors Using D greedily merge states. Running time: O(n log n) times insertion time insertion time:

◮ deterministic: O(log n) ◮ randomised O(1) Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 7 / 13

slide-20
SLIDE 20

Remarks and Questions

|Σ| has linear impact on the running time for partial δ, running time O(|δ| log2 n) can be obtained

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 8 / 13

slide-21
SLIDE 21

Remarks and Questions

|Σ| has linear impact on the running time for partial δ, running time O(|δ| log2 n) can be obtained Done independantly by Markus Holzer and Andreas Maletti, CIAA 2009.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 8 / 13

slide-22
SLIDE 22

Remarks and Questions

|Σ| has linear impact on the running time for partial δ, running time O(|δ| log2 n) can be obtained Done independantly by Markus Holzer and Andreas Maletti, CIAA 2009. Deterministic running time O(n log n)? Checking the f -equivalence of two automata is faster?

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 8 / 13

slide-23
SLIDE 23

Refinment

Definition (distance between languages)

d(L, L′) =

  • max{|u| : u ∈ L(w)∆L(w′)} + 1

if L = L′ , if L = L′ .

Definition (k-f -equivalence)

L∼kL′ ⇐ ⇒ d(L, L′) ≤ k

Definition

M is k-minimal if it has the least number of states among the ∼k automata.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 9 / 13

slide-24
SLIDE 24

Refinment

Definition (distance between languages)

d(L, L′) =

  • max{|u| : u ∈ L(w)∆L(w′)} + 1

if L = L′ , if L = L′ .

Definition (k-f -equivalence)

L∼kL′ ⇐ ⇒ d(L, L′) ≤ k

Definition

M is k-minimal if it has the least number of states among the ∼k automata.

Remark

Algorithm is similar, but some theoretical work is to be done.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 9 / 13

slide-25
SLIDE 25

Approach

Idea

Suppose there are w1, w2 with respective q1, q2 and L(w1), L(w2). We merge state q1 to q2 Intuitively, w1L(w1) changes to w1L(w2) If L(w1) = L(w2) we want k ≥ d(w1L(w1); w1L(w2)) = |w1| + d(L(w1), L(w2))

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 10 / 13

slide-26
SLIDE 26

Approach

Idea

Suppose there are w1, w2 with respective q1, q2 and L(w1), L(w2). We merge state q1 to q2 Intuitively, w1L(w1) changes to w1L(w2) If L(w1) = L(w2) we want k ≥ d(w1L(w1); w1L(w2)) = |w1| + d(L(w1), L(w2))

Definition

w1∼kw2 ⇐ ⇒ L(w1) = L(w2) or min(|w1|, |w2|) + d(L(w1), L(w2)) ≤ k

Remark

This is not an equivalence relation: it is not transitive.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 10 / 13

slide-27
SLIDE 27

Approach

Idea

Suppose there are w1, w2 with respective q1, q2 and L(w1), L(w2). We merge state q1 to q2 Intuitively, w1L(w1) changes to w1L(w2) If L(w1) = L(w2) we want k ≥ d(w1L(w1); w1L(w2)) = |w1| + d(L(w1), L(w2))

Definition

w1∼kw2 ⇐ ⇒ L(w1) = L(w2) or min(|w1|, |w2|) + d(L(w1), L(w2)) ≤ k

Remark

This is not an equivalence relation: it is not transitive.

Lemma

If {wi}ℓ

i=1 satisfy wi∼kwj then every automaton k-f -equivalent to M has

at least ℓ states.

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 10 / 13

slide-28
SLIDE 28

Adjusting the relation

Definition (Expanding for states)

For q define its representative word word(w): the longest word w such that δ(q0, w) = q. (take any word of length k + 1 if this is badly defined). q∼kq′ ⇐ ⇒ word(q)∼k word(q′)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 11 / 13

slide-29
SLIDE 29

Adjusting the relation

Definition (Expanding for states)

For q define its representative word word(w): the longest word w such that δ(q0, w) = q. (take any word of length k + 1 if this is badly defined). q∼kq′ ⇐ ⇒ word(q)∼k word(q′) Improving ∼k to an equivalence relation ≈k satisfying: w≈kw′ implies w∼kw′ equivalence class of ≈k has a representative Rep w≈kw′ implies Rep(w)∼k Rep(w′)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 11 / 13

slide-30
SLIDE 30

Adjusting the relation

Definition (Expanding for states)

For q define its representative word word(w): the longest word w such that δ(q0, w) = q. (take any word of length k + 1 if this is badly defined). q∼kq′ ⇐ ⇒ word(q)∼k word(q′) Improving ∼k to an equivalence relation ≈k satisfying: w≈kw′ implies w∼kw′ equivalence class of ≈k has a representative Rep w≈kw′ implies Rep(w)∼k Rep(w′)

Lemma

≈k can be calculated out of ∼k in a greedy fashion (using word)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 11 / 13

slide-31
SLIDE 31

k-minimal Automata

Definition (k-minimal automata N)

QN = {w : w = Rep(w)} δN(w, a) = Rep(wa)

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 12 / 13

slide-32
SLIDE 32

k-minimal Automata

Definition (k-minimal automata N)

QN = {w : w = Rep(w)} δN(w, a) = Rep(wa)

Lemma

N∼kM

Proof.

for Rep(q) s.t. | Rep(q)| > k transition structure does not change. for other states by backward induction we show that d(LM(q), LN(Rep(q))) ≤ k It is k-minimal by previous lemma.

Remark

Algorithm — refinement of the previous one

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 12 / 13

slide-33
SLIDE 33

Questions

Deterministic running time O(n log n)? Checking the k-f -equivalence of two automata is faster?

Artur Je˙ z (UWr) DFA hyper-minimisation November 24, 2009 13 / 13