HAL Id: inria-00487031
https://hal.inria.fr/inria-00487031
Submitted on 27 May 2010
HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or
L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires
Efficient Equivalence and Minimization for Non Deterministic Xor Automata
Jean Vuillemin, Nicolas Gama
To cite this version:
Jean Vuillemin, Nicolas Gama. Efficient Equivalence and Minimization for Non Deterministic Xor
Automata. [Research Report] 2010, pp.25. �inria-00487031�
Efficient Equivalence and Minimization for Non Deterministic Xor Automata
Jean Vuillemin, Nicolas Gama Ecole Normale Supérieure, Paris, France
December 18, 2009
Abstract
A wordw∈Lin a regular languageL∈ RLisor-acceptedw∈Λ∪(A) by a non-deterministic finite or-automaton A ∈ NFA if there exists a path alongwfrom some initial state to some final state inA. The same wordwis xor-accepted w∈Λ⊕(A) by the same non-deterministic finite xor-automaton A∈NXAif the number of accepting pathes isodd.
In thedeterministic caseA∈DFA, accepting pathes are unique and both definitions coincide: Λ∪(A) = Λ⊕(A). They differ the generalnon- deterministic case, whenΛ⊕(A)⊂Λ∪(A).
No polynomial time algorithm is known to minimizeNFAs or to com- pute their equivalence. By contrast, we present a cubic time algorithm to reduce a xor-automatonA∈NXAto a minimal formM = MXA(A)which acceptsΛ⊕(M) = Λ⊕(A), within the least possible number of states. It is a finite strong normal form SNF: Λ⊕(A) = Λ⊕(A0) ⇔ MXA(A) = MXA(A0)and automata equivalence is efficiently decided through reduc- tion to theSNF. The minimal number of statesd=|MXA(L)|is equal to thedimension d= dim(L)of the languageL, and the dimensiond∈N is finite if and only ifL∈ RLis regular.
The only other known finite strong normal form for a regular language Lis the classical minimal deterministic automatonMDA(L), whose num- bersof states can be exponentially larger than the dimension:d≤s≤2d. Besides efficient minimization and equivalence test (whichNFAs don’t seem to possess), we show that all other natural language operations which are efficiently handled byNFAs are just as efficiently handled byNXAs.
Contents
1 Introduction 3
1.1 Contributions . . . 4
1.2 Example X . . . 4
1.3 Plan . . . 5
2 Regular Languages 5 2.1 Letters and Words . . . 5
2.2 Languages . . . 7
2.3 Truth Table and Matrix . . . 7
2.4 Regular Languages . . . 9
2.5 Minimal Deterministic Automaton MDA . . . 10
3 Regular Dimension 10 3.1 Regular Base . . . 11
3.2 Minimal Xor Automata . . . 12
3.3 From MDA to MXA . . . 12
4 Non Deterministic Xor Automata 13 4.1 Multiple Acceptance . . . 14
4.2 Deterministic Automata . . . 16
4.3 Atomic NXA Operations . . . 16
5 Minimizing Nondeterministic Xor Automata 17 5.1 Linearly Reduced Automata . . . 18
5.2 Efficient Minimization . . . 18
5.3 Efficient NXA Operations . . . 21
6 Conclusion 22
DFA NFA NXA MXA A6=B quadratic exponential cubic constant minimize(A) lin−log(1) exponential cubic constant
¬A linear linear linear quadratic ρA exponential linear linear cubic A∗ exponential linear linear cubic A ·B exponential linear linear cubic A∪B quadratic linear quadratic cubic A⊕B quadratic quadratic linear cubic A∩B quadratic quadratic quadratic cubic
(1) MinimizingDF As has complexityO(nlog(n))by Hopcroft’s algorithm [13].
Figure 1: Complexity chart for language operations, over 4 species of automata.
1 Introduction
Regular Languages RL are the hard-core of theoreticalComputer Science. The efficient manipulation of very large automata plays a key role in more recent applications than we care to reference here - from circuits and software verifi- cation to searching huge web indexes, through logic, linguistics, speech recogni- tion/synthesis [23] and many others.
Kleene’s theorem broadly characterizes regular languages by equivalent fi- nite representations as: Regular Expressions; Deterministic DFA and Non- deterministicNFAFinite Automata;Finite Circuits andFinite Kahn Networks [17], i.e. communicating programs which only possess a finite local memory.
Since all of the above representations are finite, there existminimal size rep- resentations among each. The tricky part is to effectively find them! Among the above representations, DFAs are the only one which is known to have an easily computable minimal form, namely the Minimal Deterministic Automa- ton MDA. The MDA is a finite Strong Normal Form SNF: it is unique and characteristic of the regular language: L=L0 ⇔M DA(L) =M DA(L0). With suchSNFs [4, 21], one maps different states of the MDA to different computer memory addresses, and equivalent states to a single shared memory address.
Testing for equivalence is reduced to testing equality of addresses, in constant time.
While that most language operations are efficiently performed (fig. 1) on MDAs, it is well-known that the number of states inDFAs is, in general [16], exponential in the number of states for equivalent NFAs. So, some practical applications derived from very large automata rely on nondeterministicN F As rather deterministic ones. Indeed, most language operations are efficiently per- formed (fig. 1) onNFAs, except for two: minimization and testing for equiva- lence which have a exponential worst case complexity overNFAs.
Few explicitlyproven minimal NFAs are known [16]. Some are found through exhaustive search (up to 5 states [7, 30], see X. 2), and others through mathe-
The languageO ⊂O∗ over the one-letter alphabet{0} is equivalently defined by: O={0n: (nmod7)∈ {0,1,2,4}}. The graph of its minimal deterministic automaton MDA(O) is drawn above to the left. The graph of its minimal nondeterministic Xor automatonMXA(O)is to the right.
Figure 2: Single letter alphabet, an example from [32].
matical arguments [29]. Yet minimizingNFAs or computing their equivalence has remained computationally intractable [15] for well over half a century [18].
1.1 Contributions
Our contribution is to show that, unlikeNFAs, non-deterministic Xor automata NXA [8, 31] have a unique minimal form which can be effectively computed through linear algebra. Our minimization algorithm proceeds in two mirror passes; it has a cubic bit-level time complexity, and it only requires quadratic memory, once we compute in-place.
The result is new for alphabet sizes over two letters. It is known for the single letter alphabet, where minimization is achieved in [32] by reduction to linear feed-back shift registersand the Berlekamp-Massey algorithm [22] (fig. 2).
We finally show that all the language operations which are efficiently per- formed over N F As are also efficiently performed over N XAs (fig. 1), while keeping an efficient equivalence test and minimization procedure.
1.2 Example X
We illustrate the various constructions in this paper through the example of languageX⊂ {0,1}∗, which is equivalently defined here in various ways.
X 1 Our regular example language is first defined by X = Λ(REX), from the regular expression: REX= (1 + 0·(1 + 0·0))∗+ (1 + 0·(1 + 0·0))∗·0. Note that the regular expression REX is un-ambiguous, and both its OR and XOR interpretations (see sect. 4.1) coincide: X= Λ∪(REX) = Λ⊕(REX).
X 2 (Minimal NFA for X) An enumeration of all languages recognized by NFAs with 2 states or less shows that X is not one of them. So, the following
3 statesNFAforX is minimal: 1 0
1 0 0
.
1.3 Plan
Section 2 introduces some notations and concepts from the classical theory of regular languages, including the MDA. Section 3 defines the dimension of a regular language, and itsMXA. Section 4 introduces nondeterministic Xor au- tomata by their matrix representations. Section 5 characterizes minimalNXAs, and present efficient algorithms for operating on MXAs, and we conclude in section 6.
2 Regular Languages
The purpose of this section is to establish the terminology and notations used here forclassical automata theory.
2.1 Letters and Words
Ouralphabet A={0· · ·α−1} hasα=|A|>0 letters: l∈[0· · ·α−1]. Note that letters are ordered by0<· · ·< α−1, whenα >1.
Note: Our reader will focuss on the binary alphabet A= B ={0,1}, to gain insights and loose no generality. The special case of the unary alphabet α= 1 is treated in details by [32].
Aword u∈ An hasn=|u|lettersui∈ A: u=u1· · · · ·un. Theempty word²∈ A0 is the one and only of length0 =|²|.
Finite wordsA∗=S
n∈NAn form aMonoid underconcatenation:
∀u, v, w∈ A∗: u=²·u=u·²and(u·v)·w=u·(v·w).
Themirror ρ(u1· · ·un) =un· · ·u1 reverses the order of letters inu∈ An. Note that |u·v|=|u|+|v|andρ(u·v) =ρ(v)·ρ(u)for allu, v∈ A∗. Thenull word∅ is such that: ∀u∈ A∗: ∅ =∅ ·u=u· ∅; as for its length, we find that|∅|= log2(0) =−∞.
Total Orders on Words Lexicographic total orders on finite words are well- know, but the terminology varies between authors - e.g. [19, 9].
Definition 1 The prefix order≺is defined on wordsu, v∈ A∗ by:
1. If |u|<|v| thenu≺v.
2. If |u|=|v|, extract the first letters u=l·u0, v=l0·v0 with l, l0 < α, and letu≺v⇔(l < l0)∪((l=l0)∩(u0 ≺v0)).
We define: u¹v⇔(u≺v)∪(u=v).
3. The suffix order <is given by mirror: ∀u, v ∈ A∗ : u < v ⇔ρ u≺ρ v.
We define: u≤v⇔(u < v)∪(u=v).
Both orders are total and well-founded [19]. For the binary alphabet, we find:
∅ ≺²≺0≺1≺00≺01≺10≺11≺000≺001≺ · · ·
∅< ² <0<1<00<10<01<11<000<100<· · ·
Using the integer order symbol<rather than, say<0to denote the suffix order is justified by showing next that: ∀u, v ∈ A∗: u <0v⇔N(u)<N(v)⇔ρ u≺ρ v.
Word Number Numbering words by successive integers N(∅) = 0, N(²) = 1,· · · establishes a one-to-one correspondence, between finite (or null) words A∗∪ ∅and integersN, with both of the above orders.
Definition 2 (Suffix Number) The suffix number N(u)∈ N of a finite (or null) word u∈ W = A∗∪ ∅ counts the number N(u) = | {v∈W : v < u} | of words which precede u in suffix order. Each finite word u∈ A∗ has a unique numbern=N(u)∈N+, and conversely we let W(n) =u.
Note: An explicit formula for wordu=u0· · ·ul−1∈ Al of lengthl=|w|is
n=N(u) = 1 +X
k<l
(1 +uk)2k= 1 + bl−1 b−1 +X
k<l
uk2k.
So,nis one off (uη=N(u)−1) the reversed bijective interpretation: [9], ch. V.
In the binary alphabet2 =α, wordw=w0· · ·wl−1∈Blis numbered by the integern=N(w)∈N+whose binary representationbin(n) =w·1concatenates 1 to the right of w, i.e. n = N(w) = P
k<lwk2k + 2l. Conversely, we write n=P
k<l+1nk2k in binary to extract bin(n) =n0· · ·nl−1·1; we remove the most significant 1 bit and keep the rest: W(n) =w·1−=n0· · ·nl−1.
In general, def. 2 establishes an isomorphism between finite words u, u0 ∈ A∗=W(N+)and positive integersn, n0∈N+=N(A∗), such that
u < u0⇔N(u)<N(u0)andn < n0⇔W(n)<W(n0).
In this paper, suffix numbering lets us use integer n = N(u) ∈ N+ rather than wordu=W(n)∈ A∗ as an index to tables, matrices and series. To remain consistent, we also extend word operations to integers:
Definition 3 (Integer Mirror and Concatenation) Let the positive inte- gers uniquely number finite words inA∗ by def. 2. Forn, n0 ∈N+, we define:
• The lexicographic order by n≺n0⇔W(n)≺W(n0).
• The mirror byρ(n) =N(ρ(W(n))).
• The concatenation by n·n0 =N(W(n)·W(n0)).
Both lexicographic ≺ and integer order < apply to both integers and words:
W(n)<W(n0)⇔n < n0 andW(n)≺W(n0)⇔n≺n0. Both orders are total and well-founded.
Mirror is an involution over the integers: ∀n∈N:n=ρρ(n). In the case of the binaryα= 2alphabet, mirror is the well-knownodd-evenpermutation [20].
Positive integers form aMonoid under concatenation. For the binary alpha- betα= 2, an explicit formula for the concatenation ofn, m >0is:
n·m=n+ 2l(m−1) wherel=|n|=blog2(n)c.
2.2 Languages
A language is a (possibly infinite) setL ={u:u∈ A∗} ⊆ A∗ of finite words.
We identify the empty language with the null word: {}=∅.
Mirror ρL={ρ(v)∈ A∗:v∈L}is an involutionL=ρρ(L)overL⊆ A∗. So is the set-theoreticcomplement ¬L={v∈ A∗:v /∈L}: L=¬¬(L).
Languages are aMonoid underconcatenation: L·L0={u·u0: u∈L, u0 ∈L0}. The star L∗ ⊆ A∗ of a language L⊆ A+ (i.e. ² /∈L) is the least solution of the equation L∗ = ²∪(L·L∗), namely L∗ = P
LN where L0 = ² and LN+1=L·LN forN∈N.
It is well-known [12] that languages form aBoolean Algebra under set op- erations: complement ¬, intersection ∩ and union ∪. The Boolean Algebra is isomorphic to that of the subsets of the integers. This follows by identifying languages with integer sets through def. 2.
Languages form aBoolean Ring [12] under intersection∩and exclusive sum L⊕L0 ={u∈B∗:u∈L∪L0, u /∈L∩L0}= (L∩ ¬L0)∪(¬L∩L0).
A Boolean ring is one in which the sum is self-inverse∅=L⊕L(minus equals plus) and the product is idempotentL=L∩L(square is the identity).
Definition 4 (Suffix, Prefix) Let L⊆ A∗ be a language over alphabet A.
• The suffixu∈ A∗ of Lis the language: u−·L={v∈ A∗:u·v∈L}.
• Let suff(L) =S
u∈A∗(u−·L)denote the set of all the suffixes of L.
• The prefix u ∈ A∗ of L is the mirror L·u− = ρ(u− ·ρ(L)), that is L·u−={v∈ A∗:v·u∈L}. We let pref(L) =ρ(suff(ρ(L))).
2.3 Truth Table and Matrix
We first represent a language by its infinite binary characteristic table.
Definition 5 (Truth Table) The truth-tabletruth(L)∈F2[∞] of a language L⊆ A∗is the infinite binary vectortruth(L) = [L1· · ·Ln· · ·]defined, forn >0 byLn = 1⇔W(n)∈L.
mat(X) =
1110111101· · · 1011101100· · · 1110111101· · · 0101010001· · · 1110111101· · · 1011101100· · · 1110111101· · · 1110111101· · · 0000000000· · ·
· · ·
. (1)
Figure 3: The truth-matrix of languageX.
X 3 The truth-table of our example language is
truth(X) = [111011110110111110001· · ·].
The truth table is aStrong Normal Form forL, L0 ⊆ A∗: L=L0⇔truth(L) = truth(L0).
Infinite binary vectors form a Boolean Ringh⊕,∩iunder the bit-wise operations, defined fora, b∈F2bya∩b=abanda⊕b=a+b−2ab=a+b(mod2). They form a Boolean Algebrah¬,∪,∩iif we let¬a= 1−aanda∪b=a+b−ab.
Proposition 1 The truth-table is an isomorphism between the Boolean Ring and Algebra over languagesL, L0⊆ A∗, and those over infinite binary vectors:
truth(¬L) =¬truth(L), truth(L⊕L0) = truth(L)⊕truth(L), truth(L∪L0) = truth(L)∪truth(L), truth(L∩L0) = truth(L)∩truth(L).
f We now represent a language by the truth-tables of its suffixes/prefixes.
Definition 6 (Truth Matrix) The truth-tablemat(L)∈F2[∞,∞]ofL⊆ A∗ is the infinite binary matrixmat(L) = [Lrc ∈F2:r, c >0]defined by
Lrc = 1⇔W(ρ(r)·c)∈L.
Note: For a binary alphabet, the third rowL31···= truth(1−·L)of the truth- matrixmatL is identical to the automatic sequence associated to L ⊆ A∗ by [1, 6]. AlthoughL3isnot a normal form forL, [6] shows that theautomatic se- quenceof a regular language is algebraic, i.e. root of some polynomial equation.
It is further shown in [33, 34] that tableτ L=L11···is algebraic if and only ifL is regular, and that the characteristic P =pol (L) is a finite SNF: P is the minimal polynomial which has tableY = truthLfor root0 =P(Y) (mod 2).
The truth matrix is again aStrong Normal Form forL, L0⊆ A∗: L=L0 ⇔mat(L) = mat(L0).
Indeed, row one of mat(L) is the truth table [L11· · ·L1N· · ·] = truth(L) of L.
Note: : The formula of the truth matrix contains a mirror, whereas Hankel’s matrix which is defined byH[i, j] = 1 ⇐⇒ wi.wj ∈ L by Fliess [10] doesn’t.
The following result shows the significance of the mirror in the truth table.
Proposition 2 Let[Lrc: r, c >0] = mat(L)∈F2[∞,∞]be the truth matrix of languageL⊆ A∗. For all r, c >0:
1. Rowr of mat(L) is the truth tabletruth(ρ(r)−·L) of the suffix language u−·L, for wordu=ρW(r).
2. Columnc is the the truth table of the suffixu−·ρ L, for u=W(c).
3. Matrix bitLrc derives from the first row (or column) by:
Lrc =L1ρr·c =Lr·ρc1 .
4. The truth matrix of the mirror language is the transposed of the truth matrix: mat(ρ(L)) = mat(L)tr.
Proof: Points 1 and 3 follow by definition: mat(L)r,c = 1 ⇐⇒ ρr.c ∈L for r, c∈N. Points 1 and 3 follow by mirror: ρ(ρr.c) =ρc·r∈ρL. Q.E.D.
2.4 Regular Languages
Automata Theory [14, 24, 26] characterizesRegular LanguagesL∈RLby equiv- alent finite representations as regular expressions or automata (deterministic or not). The following classic result gives us an intrinsic characterization:
Theorem 1 (Nerode [25], Moore [24]) Language L ⊆ A∗ is regular L ∈ RLif and only if it has finitely manys=|suff(L)| ∈Nsuffix languagessuffL= {u−.L:u∈ A∗}. Integersis the minimal number of states among all (complete) deterministic automata which acceptL.
It follows from prop. 2 thats = |suff(L)| is equal to the number of different rows in the truth-matrixmat(L): s=| {Lr: r >0} |. Indeed, suffixu∈ A∗ of Lis uniquely identified by rown=N(ρ u)>0of the truth-matrix:
Ln= truth(u−.L)whereu−.L={v:u·v∈L}.
Definition 7 (Regular Index) Let L ∈ RL be a regular language, with s =
|suff(L)|different suffix languages, corresponding tos=| {Lr: r >0} |different rows in the truth-matrixmat(L).
• The minimal access pathto row Ln ismap(n) =min©
k:Lk =Lnª .
• The regular index of Lis the sequence index(L) = [n1· · ·ns] obtained by sorting all minimal pathes {map(n) :n >0} = {n1· · ·ns} in increasing order: n1< n2<· · ·< ns; clearly1 =n1, sinceL=L1.
Note: Sinces=|index(L)|, theregular index is a refined version of the classical definition in [25] who uses s = |suff(L)|. Through the mirror, index words uk =ρW(nk)uniquely appear in lexicographic order: u1=²≺u2≺ · · · ≺us. X 4 The regular index of our example language isindex(X) = [1,2,4,9], which correspond to the suffixes: X1=X,X2=X⊕0X,X4= 0XandX9=∅.
2.5 Minimal Deterministic Automaton MDA
Our reader will accept that the following definition of the MDA precedes the formal introduction of deterministic automata in sect. 4.2.
Definition 8 (Minimal Deterministic Automaton) Let L∈RL be a reg- ular language, with regular index(L) = [n1· · ·ns], and minimal access path map(n) ∈ index(L) for n > 0. The Minimal Deterministic Automaton A = (s, I, T(), F) = MDA(L)forLis:
1. The states S={n1,· · · , ns} are the elementsindex(L) = [n1· · ·ns].
2. The initial state isI= 1 =n1.
3. The final (accepting) states areF ={nk :²∈Lnk} ⊆S.
4. Transitionq0=Tl(q)is defined byq0 = map(l+b×q)∈S, for each letter l < α and stateq= map(q)∈S.
Note: TheMDAis classically [24] defined up to state isomorphism. Definition 8 makes it unique, and aStrong Normal Formfor regular languagesL, L0 ∈RL:
L=L0⇔MDA(L) = MDA(L0).
The dual normal form forL∈RLis the mirrorMDA(ρ L), withr=|index(ρ L)|
states. Yet,ris exponential insforUn =Bn·1·B∗, and conversely forρUn. X 5 The MDAof Xis represented by the graph in fig. 4.
3 Regular Dimension
A setS={L(1)· · ·L(n)· · · }of languages L(n)⊆ A∗ generates a vector space V = F2hSi= ©L
i∈SL(i) :S⊆N+ª
, under the exclusive set sum⊕ and the (trivial) scalar product: 0×V =∅and1×V =V.
By prop. 1, the vector space V = F2hSi generated by languages in S is isomorphic to the vector spaceV0 =F2htruth(L) : L∈Sigenerated by their truth-tablestruth(L)∈F2[∞].
0 1 1
1
1 0
0
0
0 1
0 1
Figure 4: The labeled graph representations of MDA(X) and MXA(X).
The dimensiond= dim(V) =|base(V)|of a finite vector spaceV =F2hSiis the minimal size of any base forV. By th. 1, the truth-matrix ofLhas finitely many different rows if and only ifL∈RL is regular. It follows that the infinite truth-matrixmat(L)has a finite rank overF2 if and only ifL∈RL.
Definition 9 (Regular Dimension) The dimension d = dim(L) ∈ N of a regular languageL∈RL is the rank of the truth-matrix:
d= dim(L) = rankF2(mat(L)).
Proposition 3 The dimension d = dim(L) of a regular language L ∈ RL is equivalently characterized by:
1. d= rankF2(mat(L))the rank of the truth matrix overF2. 2. d= dim(ρL)is the dimension of the mirror language.
3. d= dimF2hsuff(L)iis the dimension of the suffix vector space.
4. d= dimF2hpref(L)iis the dimension of the prefix vector space.
Proof: Def. (1) is definition 9. By prop. 2, the truth-matrix of the mirror language is the transposed matrix ofmat(L). Standard linear algebra [12] shows that the rank of a matrix is invariant by transposition, hence (2). Likewise, the rank of a matrix is equal to the dimension of the vector space generated by its
rows or columns, hence (3) and (4). Q.E.D.
3.1 Regular Base
The following algorithm computes the dimension of a regular language by ex- tracting a minimal base from the suffixes.
Algorithm 1 (Regular Base) Let L ∈ RL be a regular language, with reg- ular index(L) = [n1· · ·ns] and map(n) ∈ index(L) for n > 0. Let V = F2hLn1· · ·Lnsibe the vector space generated by thesdifferent suffix languages.
Fork∈[1· · ·s], we compute:
1. The dimensiondk = dimVk≤kof the vector spaceVk=F2hLn1· · ·Lnki.
2. The minimalbase(k) = [B(1)· · ·B(dk)] such thatF2hbase(k)i=F2hVki.
3. The unique decompositionud(k)⊆ {1· · ·dk} s.t. Lnk=L
i∈ud(k)B(i).
The process is initialized by: (d0= 0,base0 =∅, ud(0) = 0). We compute (dk, B(k),ubd(k))at stage k∈[1· · ·n] by considering two cases:
Case Lnk ∈/ Vk=F2hbase(k−1)i We let: dk =dk−1+ 1; basek = basek−1∪ B(k),B(k) =Lnk;ud(k) ={k}.
Case Lnk ∈Vk=F2hbase(k−1)i We let: dk = dk−1, basek = basek−1 and ud(k) =S⊆basek−1(L)is the unique decomposition Lnk=L
i∈SB(i).
At stage s, we find: the dimension d = dn = dim(V), the Regular Base base(V) = [B(1)· · ·B(d)] = [Lb1· · ·Lbd] and the unique base decomposition ubd(n) =bd(map(n))⊆ {1· · ·d} such that Ln=L
i∈ubd(n)Lbi for alln >0.
X 6 The dimension of language X is 2 = dim(X), and its regular base is base(X) = [X, X2]since (seeX4)X2=X⊕0·XandX4=X⊕X2.
3.2 Minimal Xor Automata
We anticipate again on the formal definition of automata in sec. 4, and use alg.
1 to construct the minimal non-deterministic Xor automatonMXA(L) of the regular languageL∈RL. We then relateMXA(L)to MDA(L).
Definition 10 (Minimal Xor Automaton) Let L ∈ RL be a regular lan- guage, with dimension d = dim(L), regular base base(L) = [Lb1· · ·Lbd] and unique base decompositionubd(n)⊆ {b1· · ·bd} forn >0.
The Minimal Xor AutomatonA= MXA(L) = (d, I, T(), F)∈NXAis:
1. The states S⊆B are subsets ofB={b1,· · ·, bd}.
2. The initial state isI={1}={b1}.
3. Transition q0 =Tl(q) is defined byq0 =S
i∈qubd(l+b×i)⊆ B, for each letterl < α and stateq⊆ B.
4. The final (accepting) states areF =©
bk :²∈Lbkª
⊆ B.
X 7 The graph of MDA(X) appears in fig. 4.
3.3 From MDA to MXA
For the clarity of this section, we simply consider the binary alphabet, where both the NDA and the MXA can be represented by complete binary trees (as opposed toα-ary trees, forα >2).
A characteristic property [9] of the regular index(L) = [n1· · ·ns]ofL∈RL is to be closed by suffix. In the binary case, this is simply stated by: ∀k >1 : nk÷2∈[n1· · ·nk−1].
1
2
9 1
1
1 4
9 9
1
2 1
1,2 1
Figure 5: The tree representations of MDA(X) and MXA(X).
The tree nodes of MDA(L) (def. 8) are labeled by indexes. The root is n1= 1. Fork >1, nodenk is the left (resp. right) son ofnk÷2 ifnk is even (resp. odd). Each of thes+ 1 leaves contains a back-pointer to a tree node.
The indexB={b1· · ·bd} of the regular base ofLis closed by suffix, and it is a subset of the index numbers.
The tree nodes ofMXA(L)(def. 10) are labeled by base indexes{b1· · ·bd}.
The root isb1= 1. For k >1, nodebk is the left (resp. right) son ofbk÷2 if bk is even (resp. odd). Each of thed+ 1leaves contains a (non-deterministic) set of back-pointers to tree nodes.
The tree for MXA(L)is a prefix of the tree forMDA(L). Whens > d, we reduce the MDA by replacing finding the least nk ∈ B, and by replacing the/ subtree rooted atnk by the (non-deterministic) leaf node ubd(nk). We repeat the process until there are exactlydbase nodes left: the result isMXA(L).
X 8 The tree representations of MDA(X)andMXA(X)appear in fig. 5.
4 Non Deterministic Xor Automata
Non deterministic finite automataNFAs are equivalently represented by their labeled graphs, or by their adjacency matrices [9].
We introduce Nondeterministic Xor Automata NXAs here by their matrix representation. The correspondence with the graph representation should be clear, fromNFAexperience, and from the given examples.
Definition 11 A Nondeterministic Xor Automaton A= (n, I, T(), F)∈NXA is given by:
• Integer n∈N is the number of states.
• I∈F2[1, n]is the row of initial states.
• Tl∈F2[n, n]is the transition matrix for each letter l∈B.
• F ∈N[n,1]is the column of final states.
Transition T()∈N7→F2[n, n] is extended to integers by:
T(1) = Id(n)is then×nidentity matrix;
T(l+ 1) = Tl for each letter l∈B;
T(n·m) = T(n)◦T(m)is the matrix product, forn, m >0.
ForW(n) =w1· · ·wk ∈ Ak, we find: T(n) =Tw1◦ · · · ◦Twk∈F2[n, n].
The language accepted byA is the set of wordsuwith unit trace in A:
Λ⊕(A) ={u∈ A∗: 1 =trace(I◦T(Nu)◦F)}.
X 9 The minimal nondeterministic Xor automaton for X(fig. 4) is presented by the matrices: MXA(X) = (2,[10],
· 01 11
¸ ,
· 10 10
¸ ,
· 1 1
¸ )
Definition 11 gives a method for computing bits of truth-table of the language accepted by the automaton. The bits of the truth-matrix are computed by:
Proposition 4 Let A = (n, I, T(), F)∈ NXA be a nondeterministic Xor au- tomaton forL= Λ⊕(A)∈RL. The truth-matrix mat(L) = [Lrc : r, c >0]of the accepted languageLis equal to:
∀r, c >0 : Lrc=trace(I◦T(ρ r)◦T(c)◦F). (2) Proof: By definitions 10 and 5 we know that: W(c)∈L⇔L1c = 1, for allc >0;
it follows thatL1c =trace(I◦T(1)◦T(c)◦F), whereT(1) =Id(n)is the identity.
So,[trace(A(c)) :c >0]is the first row of the truth-matrix, i.e. the truth table ofL=L1. Proposition 2 derives the other rows byLrc =L1ρ r·c, and it simply follows thatLrc =trace(I◦T(ρ r·c)◦F) =trace(I◦T(ρ r)◦T(c)◦F). Q.E.D.
4.1 Multiple Acceptance
Definition 11 uses theh⊕,∩iscalar product over the Boolean RingF2: R◦⊕C= M
1≤k≤n
rkck= (S mod2)whereS= X
1≤k≤n
rkck. (3)
RegardingF2as a Boolean Algebra underh∪,∩ichanges the scalar product to:
R◦∪C= [
1≤k≤n
rkck = (S >0)whereS= X
1≤k≤n
rkck. (4)
Both are derived from the usual scalar producth+,×iover the integers:
R◦+C= X
1≤k≤n
rkck. (5)
Let us read again def. 11, and consider in turn the implications of each of the three choices for the scalar product:
◦+ With ordinary matrix product h+,×i over integers, the traceµ(n, A) = trace(I◦+T(Nu)◦+F)ofuinAis known [27, 9] as themultiplicity, since integerµ(n, A)counts the number of pathes along wordufrom all initial to all final states in the graph ofA.
◦∪ With matrix producth∪,∩i, the traceto=trace(I◦∪T(Nu)◦∪F)ofuin Ais 1 if and only if there exists a path alongufrom some initial state to some final state, i.e. to= 1⇔µ(n, A)>0. The accepted languageΛ∪(A) is the classically defined ([9] ch. VI) one forA∈NFA.
◦⊕ With producth⊕,∩i, the tracetx=trace(I◦⊕T(Nu)◦⊕F)ofuin Ais 1 if and only if the number of pathes along ufrom initial states to final states is odd, i.e. tx= (µ(n, A)mod2). By def. 11, the language Λ⊕(A) is accepted by theNondeterministic Xor Automaton A∈NXA.
The two dualor /xor languages accepted by automatonAare:
1. Λ∪(A) ={u∈ A∗: µ(u, A)>0}, as defined forA∈NFA.
2. Λ⊕(A) ={u∈ A∗: 1 = (µ(u, A)mod2)}, as defined forA∈NXA.
Both languages are such thatΛ⊕(A)⊆Λ∪(A).
Both are different if and only if the multiplicity of some word is not zero but even: Λ⊕(A)6= Λ∪(A)⇔ ∃u∈ A∗:µ(u, A) = 2kfork >0.
Both languages are equal Λ⊕(A) = Λ∪(A) when automaton A ∈ DFA is deterministic(sect. 4.2). Indeed, it follows in this case [9] that the multiplicity of each word is either 0 or 1: ∀u∈ A∗ : µ(u, A)∈B, hence Λ⊕(A) = Λ∪(A).
Note: Linear automata are introduced by Schützenberger [28] over Z. They are extended to ringsK by Fliess [11]. Definitions 9 and 11 of the dimension and xor acceptance are special cases of [11], once we specialize K = F2 to the Boolean Ring. Likewise, the xor automata are a special case forF2 of the weighted automatain [3, 23].
X 10 The n-th power of the transition matrixX0=
· 01 11
¸
inMXA(X)(X9) is expressed (X0)n =
· Fn−1Fn
FnFn+1
¸
by Fibonacci [19] numbers: F0 = 0,F1= 0 andFn+2=Fn+1+Fn. The multiplicity of word0n inMXA(X)is equal toFn, which is an even number if and only ifnis a multiple of 3. Using this fact, we can characterize the words ofX⊂B∗ by:
u∈X⇔u= 1∗0a11+0a2· · ·1+0ak1∗,
for allk∈N, with1+= 1·1∗ and26= (ai mod3) fori∈[1· · ·k].
Note: The question of multiple acceptance applies to regular expressions as well as toN F As. For example, word 0 has multiplicity 2 in the regular expression 0 + 0. In general, the multiplicityµ(u, E)∈Nof worduin a regular expression Eis the number of ways to parseuaccording toE. The OR-accepted language isΛ∪(E) ={u∈ A∗: µ(u, E)>0}. The XOR-accepted language is Λ⊕(E) = {u∈ A∗: µ(u, E) = 1 (mod 2)}. They are different if and only if some word has an even multiplicity inE. Efficient translations are known between regular expressions and NFA, such as [2] which also preserves multiplicity. It follows that a theory of XOR-accepting regular expressions can be developed, alongside that ofNXAs.
X 11 The regular expression RX = (0 + 1 + 00)∗ is such that Λ⊕(RX) =X, whileΛ⊕(RX) =B∗.
4.2 Deterministic Automata
The matrices for the MDA(L) = (s, I, T(), F) in def. 8 are: I = [10s−1] and Tl[r, c] = 1 ⇔ c = map(r), for all r, c ∈ [1· · ·s] and l < α. Note that, by construction, each row contains exactly one bit at 1.
Definition 12 (Stochastic Binary Matrices) A matrix M ∈ F2[n, m] is row stochasticif each row contains a single one:
∀c∈[1· · ·m] : 1 = X
1≤r≤n
Mcr.
Definition 13 (DFA) AutomatonA= (n, I, T(), F)∈NXAis a Determinis- tic (complete) Finite AutomatonA∈DFA if its matricesI andTl (forl < α) are row stochastic (exactly one bit at 1).
X 12 The minimal deterministic automaton for X is presented by the row stochastic matrices: MDA(X) = (4,[1000],
0100 0010 1000 0001
,
1000 1000 0001 0001
,
1 1 0 0
).
The following is a classical [9] characterization ofminimal DFAs:
Proposition 5 A deterministic automatonA= (n, I, T(), F)∈DFAaccepting L= Λ(A)is minimalif and only if:
1. The number of states is equaln=|suf f ix(L)| to the number of suffixes.
2. All states are accessible, and all recognize different languages: q=q0 ⇔ Λ(A[I=q]) = Λ(A[I=q0]).
3. Automaton Ais isomorphic to MDA(A).
4.3 Atomic NXA Operations
All NXA algorithms in sect. 5 rely on three atomic operations:
Definition 14 (Atomic NXA Operations) Let A = (n, I, T(), F) be a xor automatonA∈NXA.
Mirror The mirror (a.k.a. transposed) A0 = ρ A = Atr ∈ NXA of A is the xor automaton A0 = (n, Ftr, Ttr(), Itr) where matrix Tl0 = Tltr is the transposed of matrixTl, for each letter l∈B.
Similitude Let P, P− ∈ F2[n, n] be an inverse P ◦P− = Idn matrix pair.
AutomatonA0 =P◦A◦P−∈NXAis defined byA0 = (n, I◦P, T0(), P−◦F) whereTl0=P−◦Tl◦P, for each letter l∈B.
Shrink Automaton A0 = shrink(A, d) = (d, I0, T0(), F0) results by removing rows & columnsk, for d < k≤n, from all matrices inA.
Note that the transposed automatonA0 =Atr recognizes the mirror language Λ⊕(A0) =ρΛ⊕(A)within the same number of states (and transitions).
Similar automata A and A0 = P ◦A◦P− recognize the same language Λ⊕(A0) = Λ⊕(A0)within the same number of states.
AutomatonA0 = shrink(A, d)recognizes the same language asA, with only d states, if none of the k-th state Dk = [0k−110n−k] is accessible, i.e. Dk ∈/ {I◦T(n) : n >0}ford < k≤n.
5 Minimizing Nondeterministic Xor Automata
Except for the reference to MXA (def. 10), the following characterization of minimal Xor automata is a special case (for the ringK=F2) of a theorem by Fliess [10] on minimal linear automata.
Proposition 6 • The regular dimension dim(L)is lower than the number of states in allA∈NXAforL= Λ⊕(A).
• Automaton A = (n, I, T(), F)∈ NXAfor L = Λ⊕(A) is minimal if and only if:
1. The number nof states is equaln= dim(L)to the dimension ofL.
2. All states are accessible and linearly independent:
∀q: Λ⊕(A[I=q])∈/F2hΛ⊕(A[I=q0] :q0 6=q)i.
3. The mirrorρA ofA is minimal.
4. AutomatonA is similar toMXA(A).
X 13 The NXAS=P◦C◦P− is similar toC= MXA(X)(see X9) through P =
· 10 11
¸
=P− (mod 2). It is equivalently represented by its matrices S =
(2,[10],
· 11 10
¸ ,
· 10 00
¸ ,
· 1 0
¸
), and by its graph: 0+1 0
0
. By exhaustive enumeration, we verify that S has both minimal number of states and transitions among allNXAs forX.
Abstract algorithms are known ([10, 3]) for minimizing linear automata over abstract rings K, in polynomial time. We introduce here an efficient (cubic time, quadratic storage) minimization algorithm over the concrete 2-elements field K = F2. It finds the MXA in two mirror stages, like Brzozowski’s [5]
(exponential time, see [35]) algorithm for computing theMDA.
5.1 Linearly Reduced Automata
Linear reducibility is toMXAs what accessibility is toDFAs:
Definition 15 (Linearly Reduced) LetA= (n, I, T(), F)be aNXA, and let A={I◦T(ρ(m)) :m >0} represent its accessible configurations.
• A is linearly reduced if the number of states is equal to the dimension of the vector space generated by the accessible configurations: n= dimF2hAi.
• A is linearly co-reduced if the mirrorρAis linearly reduced.
Sincen= dimF2hAi, we can extract a minimal base of sizenforA.
Definition 16 (Base Matrices) Let A= (n, I, T(), F)be linearly reduced.
• The Row Access Base R= rab(A)∈F2[n, n] of A ∈NXA is the matrix whose rowk∈[1· · ·n]is defined byRk1···n=I◦T(ρ rk), for the base index
rk= min©
m: I◦T(ρ m)∈/ F2hR1· · · Rk−1iª .
• Automaton Ais in diagonal formif Id(n) = rab(A).
By construction, the n×n row access matrix R = rab(A) of a linearly reduced automaton A ∈ NXA has full rank: n = rankF2R. It follows from linear algebra [12] that matrixRhas a unique inverse R− ∈F2[n, n]such that Id(n) = R ◦ R−. Among all automata which are similar to A, automaton R ◦A◦ R− is the only one which is in diagonal form.
Note the minimal automata Lx= MXA(L) (def. 10) and Ld = MDA(L) (def. 8) of a regular language L ∈ RL are both linearly reduced, since both matrix representations are in diagonal form: rab(Lx) = Id(d) for d= dimL, andrab(Ld) =Id(s)fors=|suff(L)|. It follows that:
Proposition 7 (Minimal Diagonal Forms) Let L ∈ RL be a regular lan- guage withs=|suff(L)|suffixes and dimension d= dimL.
• Among all minimal (s states) deterministicDFAs for L, the MDA(L) is the unique automaton in diagonal form.
• Among all minimal (dstates) nondeterministicNXAs forL, theMXA(L) is the unique automaton in diagonal form.
5.2 Efficient Minimization
Our key theoretical contribution is the following:
Theorem 2 A nondeterministic automatonA= (n, I, T(), F)∈NXAforL= Λ⊕(A)∈RL is minimal n=d= dim(L)if and only if both A and its mirror ρAare linearly reduced.
Proof: It follows from prop. 6.2 that a minimaln=dautomatonAis linearly reduced; so is the mirrorρAby prop. 6.3. Hence, minimality ofAimplies that it is linearly reduced, in both ways.
Conversely, we already know that n≥dby prop. 6. We prove that n≤d by considering then×n row base matrix R= rab(A) (def. 16), and the dual column base matrix obtained by mirror and transposition: C= rab(ρ A)tr. We letubd(A) = [r1· · ·rn]andubd(ρA) = [c1· · ·cn].
SinceAandρ A are linearly reduced, both matrices and their productP = R◦Chave full rank: n= rankF2R= rankF2C= rankF2P.By def. 16, the bits of matrixP are extracted from the truth-matrix ofLsinceP[i, j] =Lrcij. It follows that the ranknof the sub-matrixP is bounded by thatd= rankF2mat(L)of
the full truth-matrix, hence finallyn=d. Q.E.D.
It follows from th. 2 that we can construct a minimal automaton equivalent to A∈NXA by linearly reducing its rows and columns. Alg. 3 is an efficient reduction todiagonal form, and we use it twice to directly construct theMXA of the accepted language:
Algorithm 2 (Minimization by Mirrors) Let A be a NXA which accepts the language L = Λ⊕(A). Let diag be a procedure which reduces an arbitrary NXAto its diagonal form. We compute the Minimal Xor Automaton of L by:
MXA(L) = diag(ρdiag(ρ A)).
Kronecker’s delta symbol is defined by: δ(0) = 1, andδ(n) = 0for n >0. We letD1· · ·Dn denote the rows Dk[r] =δ(r−k)of the identity matrix.
Algorithm 3 (Diagonal Reduction) Let A = (n, I, T(), F) ∈ NXA be a nondeterministic XOR automaton forL= Λ⊕(A)∈RL we construct an equiv- alentL= Λ⊕(A0)automatonA0 = diag(A)∈NXAwhich is linearly reduced in diagonal formby:
f un M = diag(A) : A, M ∈MXA
{ var Q∈F IF O; //Queue Q
Q:=push(A.I); // InitializeQ to vectorI
d:= 0; //Initial dimension
while Q6=∅ do // Repeat until empty:
{ C:=pop(Q) // Explore next configuration if ∃k > d: 1 =C[k] then // C /∈F2[D1· · ·Dd] { //Push the configurations accessed fromC ontoQ:
f or (l < α) do Q:=push(A.T[l]);
(P, P−) :=pivot(d, k, C); //Compute the pivot matrices A:=P◦A◦P−; // Diagonalize rowd+ 1
d:=d+ 1; //Increase the dimension
} else {}} //Do nothing: C∈F2[D1· · ·Dd] A:= shrink(A, d);// Eliminate un-accessible states [d+ 1· · ·n]:
return(A). }
Note: In alg. 3, it is important to store the configurations to be explored in First-In First-OutFIFO order. Using a different queue order would still yield a linearly reduced automaton, but it would no longer be in canonical form. The chosen order traverses the accessible configurations I◦T(ρn) in breadth first manner, i.e. lexicographic order over wordswW(ρn), i.e. hierarchical order over nodes in the tree representation.
Algorithm 4 (Pivot) In the notations of alg. 3 the pivot matrices(P, P−) = pivot(d, k, C)are defined, for a rowC∈F2[n] such that1 =C[k]withd < k ≤ n, by the pair of inverse matricesP=Q◦GandP−=G◦Qwhere:
• MatrixQ=Q− permutes the columnsd+ 1 andk.
• Let R=C◦Q∈F2[n]be the permuted row, such that1 =R[d+ 1].
• Matrix G=G− is the identity matrix, except for row d+ 1 which is R:
G[r, c] =if (r=d+ 1)then R[c]elseδ(r−c), for 1≤r, c≤n.
X 14 Alg. 3 reduces the four states deterministic A= MDA(X)(X12) to the two states nondeterministicC= MXA(X)(X9) as follows:
B= diag(Atr) = (2,[11],
· 01 11
¸ ,
· 11 00
¸ ,
· 1 0
¸ ), C= diag(Btr) = (2,[10],
· 01 11
¸ ,
· 10 10
¸ ,
· 1 1
¸ ).
Note thatA= diag(A)sinceA= MDA(X)is already in diagonal reduced form.
Proposition 8 Algorithm 3 reduces A ∈ NXA, with n states, to its diagonal formB = diag(A), with m≤n states, all in timeO(m×n2)(bit operations), and space2n(n+ 1) (bits).
Proof: Each FIFO entry is written and read exactly once. We let F1· · ·Fs
represent the entire FIFO history, at the end of the procedure. It contains all visited configurationsFk =I◦T(ρ nk)∈F2[1, n], in order1 =n1< n2<· · ·<
ns. The visit wordswk=W(nk)are thus in lexicographic order ²=w1≺w2≺
· · · ≺ws, and they form a prefix-closed set: indeed, all pushed configurations push(A.T[l]) extend a word by one letter, i.e. wi =wj·l for some j < iand letterl∈ A. It follows that F2[F1· · ·Fs] =F2hI◦T(n) : n >0i.
Each visited configuration, forj ∈[1· · ·s], is either a base configuration if Fj ∈/ F2[F1· · ·Fj−1], or it is adependent configuration ifFj ∈F2[F1· · ·Fj−1].
Base configurations correspond to internal nodes, and dependent ones to leaves, in the completeα-ary tree representation. It follows that the number of visited configurations is proportionals= 1 + (α−1)mto the final dimensionm.
We let [b1· · ·bm] denote the minimal access pathes bdj = nj to the base configurations Fj = I ◦T(ρ nj). The set inclusion ubd(L) ⊆ {b1· · ·bm} ⊆ index(L) can be noted, whereubd(L)is the minimal base index (alg. 1) and index(L)is the regular index (def. 7) ofL= Λ⊕(A).