A Quasiorder-based Perspective on Residual Automata
AA Quasiorder-based Perspective on ResidualAutomata
Pierre Ganty
IMDEA Software Institute, Madrid, [email protected]
Elena Gutiérrez
IMDEA Software Institute, Madrid, SpainUniversidad Politécnica de Madrid, [email protected]
Pedro Valero
IMDEA Software Institute, Madrid, SpainUniversidad Politécnica de Madrid, [email protected]
Abstract
In this work, we define a framework of automata constructions based on quasiorders over words toprovide new insights on the class of residual automata. We present a new residualization operationand a generalized double-reversal method for building the canonical residual automaton for a givenlanguage. Finally, we use our framework to offer a quasiorder-based perspective on NL ∗ , an onlinelearning algorithm for residual automata. We conclude that quasiorders are fundamental to residualautomata as congruences are to deterministic automata. Formal languages and automata theory → Regular languages
Keywords and phrases
Residual Automata, Quasiorders, Double-Reversal Method, Canonical RFA,Regular Languages
Funding
All authors were partially supported by the Spanish project PGC2018-102210-B-I00 BOSCO
Pierre Ganty : Partially supported by the Madrid regional project S2018/TCS-4339 BLOQUES andthe Ramón y Cajal fellowship RYC-2016-20281.
Elena Gutiérrez : Partially supported by the BES-2016-077136 grant from the Spanish Ministry ofEconomy, Industry and Competitiveness.
Residual automata (RFAs for short) are finite-state automata for which each state defines a residual of its language, where the residual of a language L by a word u is defined as theset of words w such that uw ∈ L . The class of RFAs lies between deterministic (DFAs)and nondeterministic automata (NFAs). They share with DFAs a significant property: theexistence of a canonical minimal form for any regular language. On the other hand, they sharewith NFAs the existence of automata that are exponentially smaller (in the number of states)than the corresponding minimal DFA for the language. These properties make RFAs speciallyappealing in certain areas of computer science such as Grammatical Inference [10, 13].RFAs were first introduced by Denis et al. [8, 9]. They defined an algorithm for resid-ualizing an automaton, which is a variation of the well-known subset construction used fordeterminization, and showed that there exists a unique canonical RFA, which is minimal inthe number of states, for every regular language. Moreover, they showed that the residual-equivalent of the double-reversal method [4] holds, i.e. residualizing an automaton N whosereverse is residual yields the canonical RFA for the language accepted by N .Later, Tamm [15] generalized the double-reversal method for RFAs by giving a sufficient a r X i v : . [ c s . F L ] J u l A Quasiorder-based Perspective on Residual Automata and necessary condition that guarantees that the residualization operation defined by Deniset al. [9] yields the canonical RFA. In fact, this generalization comes in the same lines as thatof Brzozowski and Tamm [5] for the double-reversal method for building the minimal DFA.These results evidence the existence of a relationship between RFAs and DFAs. In fact,a connection between these two classes of automata was already established by Myers etal. [1, 14] from a category-theoretical point of view. Concretely, they [1] use this perspectiveto address the residual-equivalent of the double-reversal method proposed by Denis et al. [9]to obtain the canonical RFA.In this work we evidence this connection between RFAs and DFAs from the point of viewof quasiorders over words. Specifically, we show that quasiorders are fundamental to RFAsas congruences are for DFAs.Previously, we studied the problem of building DFAs using congruences, i.e., equivalencerelations over words with good properties w.r.t. concatenation [11]. This way, we derivedseveral well-known results about minimization of DFAs, including the double-reversal methodand its generalization by Brzozowski and Tamm [5]. While the use of congruences overwords suited for the construction of a subclass of residual automata, namely, deterministic automata, these are no longer useful to describe the more general class of nondeterministic residual automata. By moving from congruences over words to quasiorders , we are able tointroduce nondeterminism in our automata constructions.We consider quasiorders with good properties w.r.t. right and left concatenation. Inparticular, we define the so-called right language-based quasiorder, whose definition relies ona given regular language; and the right automata-based quasiorder, whose definition relieson a finite representation of the language, i.e., an automaton. We also give counterpartdefinitions for quasiorders that behave well with respect to left concatenation. Relying onquasiorders that preserve a given regular language, i.e., the closure of the language w.r.t. thequasiorder coincides with the language, we will provide a framework of finite-state automataconstructions for the language.When instantiating our automata constructions using the right language-based quasiorder,we obtain the canonical RFA for the given language; while using the right automata-basedquasiorder yields an RFA for the language accepted by the automaton that has, at most, asmany states as the RFA obtained by the residualization operation defined by Denis et al. [9].Similarly, left automata-based and language-based quasiorders yield co-residual automata,i.e., automata whose reverse is residual.Our quasiorder-based framework allows us to give a simple correctness proof of thedouble-reversal method for building the canonical RFA. Moreover, it allows us to generalizethis method in the same fashion as Brzozowski and Tamm [5] generalized the double-reversalmethod for building the minimal DFA. Specifically, we give a characterization of the class ofautomata for which our automata-based quasiorder construction yields the canonical RFA.We compare our characterization with the class of automata, defined by Tamm [15], forwhich the residualization operation of Denis et al. [9] yields the canonical RFA and showthat her class of automata is strictly contained in the class we define. Furthermore, wehighlight the connection between the generalization of Brzozowski and Tamm [5] and theone of Tamm [15] for the double-reversal methods for DFAs and RFAs, respectively.Finally, we revisit the problem of learning residual automata from a quasiorder-basedperspective. Specifically, we observe that the NL ∗ algorithm defined by Bollig et al. [3],inspired by the popular Angluin’s L ∗ algorithm for learning DFAs [2], can be seen as analgorithm that starts from a quasiorder and refines it at each iteration. At the end ofeach iteration, the automaton built by NL ∗ coincides with our quasiorder-based automata . Ganty and E. Gutiérrez and P. Valero 3 construction applied to the refined quasiorder. Structure of the paper.
After preliminaries in Section 2, we introduce in Section 3automata constructions based on quasiorders and establish the duality between these con-structions when using right and left quasiorders. We instantiate these constructions inSection 4 with the language-based and automata-based quasiorders and study the relationsbetween the resulting automata. As a consequence, we derive in Section 5 a generalizationof the double-reversal method for building the canonical RFA for a language. In addition,we show a novel quasiorder-based perspective on the NL ∗ algorithm for learning residualautomata in Section 6. Finally, Appendix A includes a formal description of the NL ∗ al-gorithm, Appendix B is dedicated to supplementary results, including the pseudocode of ourquasiorder-based version of NL ∗ , and Appendix C contains all the deferred proofs. Languages.
Let Σ be a finite nonempty alphabet of symbols. Given a word w ∈ Σ ∗ , we willuse | w | to denote the length of w . We denote w R the reverse of w . Given a language L ⊆ Σ ∗ , L R def = { w R | w ∈ L } denotes the reverse language of L and L c , its complement language.We denote the left (resp. right) quotient of L by a word u , also known as residual , as u − L def = { w ∈ Σ ∗ | uw ∈ L } (resp. Lu − def = { w ∈ Σ ∗ | wu ∈ L } ). Denis et al. [9] definedthe notion of composite and prime residuals that we extend to right quotients as follows. Aleft (resp. right) quotient u − L (resp. Lu − ) is composite iff it is the union of all the left(resp. right) quotients that it strictly contains, i.e. u − L = S x ∈ Σ ∗ , x − L (cid:40) u − L x − L (resp. Lu − = S x ∈ Σ ∗ , Lx − (cid:40) Lu − Lx − ). Otherwise, we say the quotient is prime . Automata. A (nondeterministic) finite-state automaton (NFA for short), or simply auto-maton , is a 5-tuple N = ( Q, Σ , δ, I, F ), where Q is a finite set of states , Σ is an alphabet, I ⊆ Q are the initial states, F ⊆ Q are the final states, and δ : Q × Σ → ℘ ( Q ) is the transition function, where ℘ ( Q ) denotes the powerset w.r.t. Q . We denote the extended transition func-tion from Σ to Σ ∗ by ˆ δ , defined in the usual way, and, given w ∈ Σ ∗ and S ∈ ℘ ( Q ), we definepost N w ( S ) def = { q ∈ Q | ∃ q ∈ S, q ∈ ˆ δ ( q , w ) } and pre N w ( S ) def = { q ∈ Q | ∃ q ∈ S, q ∈ ˆ δ ( q, w ) } .Given S, T ⊆ Q , W N S,T def = { w ∈ Σ ∗ | ∃ q ∈ S, q ∈ T, q ∈ ˆ δ ( q, w ) } . In particular, when S = { q } and T = F , we say that W N q,F is the right language of state q . Likewise, when S = I and T = { q } , we say that W N I,q is the left language of state q . In general, we omit theautomaton N from the superscript when it is clear from the context. We say that a state q is unreachable iff W N I,q = ∅ and we say that q is empty iff W N q,F = ∅ . Finally, the languageaccepted by an automaton N is L ( N ) = S q ∈ I W N q,F = S q ∈ F W N I,q = W N I,F .The NFA N = ( Q , Σ , δ , I , F ) is a sub-automaton of N iff Q ⊆ Q , I ⊆ I , F ⊆ F and q ∈ δ ( q, a ) ⇒ q ∈ δ ( q, a ) with q, q ∈ Q and a ∈ Σ. The reverse of N , denoted by N R , isdefined as N R = ( Q, Σ , δ r , F, I ) where q ∈ δ r ( q , a ) iff q ∈ δ ( q, a ). Clearly, L ( N ) R = L ( N R ). Residual Automata. A residual finite-state automaton (RFA for short) is an NFA suchthat the right language of each state is a left quotient of the accepted language. We writeRFA instead of RFSA [9] to be consistent with the abbreviations NFA and DFA. Formally,an RFA is an automaton N = ( Q, Σ , δ, I, F ) such that ∀ q ∈ Q, ∃ u ∈ Σ ∗ , W N q,F = u − L ( N ).We say an automaton is co-residual (co-RFA for short) if its reverse is an RFA, i.e., ∀ q ∈ Q, ∃ u ∈ Σ ∗ , W N I,q = L ( N ) u − . We say u ∈ Σ ∗ is a characterizing word for q ∈ Q iff W N q,F = u − L ( N ) and we say N is consistent iff every state q is reachable by a characterizingword for q . Moreover, N is strongly consistent iff every state q is reachable by everycharacterizing word of q . A Quasiorder-based Perspective on Residual Automata
Denis et al. [9] define a residualization operation that, given NFA N , builds an RFA N res such that L ( N res ) = L ( N ). Let N = ( Q, Σ , δ, I, F ) be an NFA and u ∈ Σ ∗ , the set post N u ( I )is coverable iff post N u ( I ) = S x ∈ Σ ∗ , post N x ( I ) (cid:40) post N u ( I ) post N x ( I ). Define N res def = ( e Q, Σ , e δ, e I, e F )as an RFA with e Q = { post N u ( I ) | u ∈ Σ ∗ ∧ post N u ( I ) is not coverable } , e I = { S ∈ e Q | S ⊆ I } , e F = { S ∈ e Q | S ∩ F = ∅ } and e δ ( S, a ) = { S ∈ e Q | S ⊆ δ ( S, a ) } for every S ∈ e Q and a ∈ Σ.Finally, the canonical
RFA for a regular language L is the RFA C def = ( Q, Σ , δ, I, F ) with Q = { u − L | u ∈ Σ ∗ ∧ u − L is prime } , I = { u − L ∈ Q | u − L ⊆ L } , F = { u − L ∈ Q | ε ∈ u − L } and δ ( u − L, a ) = { v − L ∈ Q | v − L ⊆ a − ( u − L ) } for every u − L ∈ Q and a ∈ Σ. Asshown by Denis et al. [9], the canonical RFA is a strongly consistent RFA and it is theminimal (in number of states) RFA such that L ( N ) = L . Moreover, the canonical RFA ismaximal in the number of transitions. Quasiorders. A quasiorder over Σ ∗ (qo for short) (cid:52) is a reflexive and transitive binaryrelation over Σ ∗ . A symmetric qo is called an equivalence relation . A quasiorder (cid:52) is a right (resp. left) quasiorder and we denote it (cid:52) r (resp. (cid:52) ‘ ) iff for all u, v ∈ Σ ∗ , we havethat u (cid:52) v ⇒ ua (cid:52) va (resp. u (cid:52) v ⇒ au (cid:52) av ), for all a ∈ Σ. For example, the quasiorderdefined by u (cid:52) len v def ⇐⇒ | u | ≤ | v | , is a left and right qo but not an equivalence relation.Given two qo’s (cid:52) and (cid:52) , we say that (cid:52) is finer than (cid:52) (or (cid:52) is coarser than (cid:52) ) iff (cid:52) ⊆ (cid:52) . For every qo (cid:52) , we define its strict version as: u ≺ v def ⇐⇒ u (cid:52) v ∧ v (cid:52) u andwe define ( (cid:52) ) − as: u ( (cid:52) ) − v def ⇐⇒ v (cid:52) u . Note that every qo (cid:52) induces an equivalencerelation defined as ∼ def = (cid:52) ∩ ( (cid:52) ) − .We adopt the definition of closure of a subset of S ⊆ Σ ∗ w.r.t. a qo (cid:52) introduced by deLuca and Varricchio [7]. Concretely, given a qo (cid:52) on Σ ∗ and a subset S ⊆ Σ ∗ , we definethe upper closure (or simply closure ) of S w.r.t. (cid:52) as cl (cid:52) ( S ) def = { w ∈ Σ ∗ | ∃ x ∈ S, x (cid:52) w } .We say that cl (cid:52) ( S ) is a principal iff cl (cid:52) ( S ) = cl (cid:52) ( { u } ), for some u ∈ Σ ∗ . In that case, wewrite cl (cid:52) ( u ) instead of cl (cid:52) ( { u } ). Note that, cl (cid:52) ( u ) = cl (cid:52) ( v ), for all v ∈ Σ ∗ such that u ∼ v .Finally, given a language L ⊆ Σ ∗ , we say that a qo (cid:52) is L - preserving iff cl (cid:52) ( L ) = L . We will consider right and left quasiorders on Σ ∗ (and their corresponding closures) and wewill use them to define RFAs constructions for regular languages. The following lemma givesa characterization of right and left quasiorders. (cid:73) Lemma 1.
The following properties hold: (cid:52) r is a right quasiorder iff cl (cid:52) r ( u ) v ⊆ cl (cid:52) r ( uv ) , for all u, v ∈ Σ ∗ . (cid:52) ‘ is a left quasiorder iff v cl (cid:52) ‘ ( u ) ⊆ cl (cid:52) ‘ ( vu ) , for all u, v ∈ Σ ∗ . Given a regular language L , we are interested in left and right quasiorders that are L -preserving. We will use the principals of these quasiorders as states of automata constructionsthat yield RFAs and co-RFAs accepting the language L . Therefore, in the sequel, we willonly consider quasiorders that induce a finite number of principals, i.e., quasiorders (cid:52) suchthat the induced equivalence ∼ def = (cid:52) ∩ ( (cid:52) ) − has finite index.Next, we introduce the notion of L -composite principals which, intuitively, correspondto states of our automata constructions that can be removed without altering the languageaccepted by the automata. (cid:73) Definition 2 ( L -Composite Principal) . Let L be a regular language and let (cid:52) r (resp. (cid:52) ‘ )be a right (resp. left) quasiorder on Σ ∗ . Given u ∈ Σ ∗ , the principal cl (cid:52) r ( u ) (resp. cl (cid:52) ‘ ( u ) ) . Ganty and E. Gutiérrez and P. Valero 5 is L - composite iff u − L = [ x ∈ Σ ∗ , x ≺ r u x − L ( resp. Lu − = [ x ∈ Σ ∗ , x ≺ ‘ u Lx − ) If cl (cid:52) r ( u ) (resp. cl (cid:52) ‘ ( u ) ) is not L -composite then it is L -prime . We sometimes use the terms composite and prime principal when the language L is clearfrom the context. Observe that, if cl (cid:52) r ( u ) is L -composite, for some u ∈ Σ ∗ , then so is cl (cid:52) r ( v ),for every v ∈ Σ ∗ such that u ∼ r v . The same holds for a left quasiorder (cid:52) ‘ .Given a regular language L and a right quasiorder (cid:52) r that is L -preserving, the followingautomata construction yields an RFA that accepts exactly the language L . (cid:73) Definition 3 (Automata construction H r ( (cid:52) r , L ) ) . Let (cid:52) r be a right quasiorder and let L ⊆ Σ ∗ be a language. Define the automaton H r ( (cid:52) r , L ) def = ( Q, Σ , δ, I, F ) where Q = { cl (cid:52) r ( u ) | u ∈ Σ ∗ , cl (cid:52) r ( u ) is L -prime } , I = { cl (cid:52) r ( u ) ∈ Q | ε ∈ cl (cid:52) r ( u ) } , F = { cl (cid:52) r ( u ) ∈ Q | u ∈ L } and δ (cl (cid:52) r ( u ) , a ) = { cl (cid:52) r ( v ) ∈ Q | cl (cid:52) r ( u ) a ⊆ cl (cid:52) r ( v ) } for all cl (cid:52) r ( u ) ∈ Q, a ∈ Σ . (cid:73) Lemma 4.
Let L ⊆ Σ ∗ be a regular language and let (cid:52) r be a right L -preserving quasiorder.Then H r ( (cid:52) r , L ) is an RFA such that L ( H r ( (cid:52) r , L )) = L . Given a regular language L and a left L -preserving quasiorder (cid:52) ‘ , we can give a similarautomata construction of a co-RFA that recognizes exactly the language L . (cid:73) Definition 5 (Automata construction H ‘ ( (cid:52) ‘ , L ) ) . Let (cid:52) ‘ be a left quasiorder and let L ⊆ Σ ∗ be a language. Define the automaton H ‘ ( (cid:52) ‘ , L ) = ( Q, Σ , δ, I, F ) where Q = { cl (cid:52) ‘ ( u ) | u ∈ Σ ∗ , cl (cid:52) ‘ ( u ) is L -prime } , I = { cl (cid:52) ‘ ( u ) ∈ Q | u ∈ L } , F = { cl (cid:52) ‘ ( u ) ∈ Q | ε ∈ cl (cid:52) ‘ ( u ) } ,and δ (cl (cid:52) ‘ ( u ) , a ) = { cl (cid:52) ‘ ( v ) ∈ Q | a cl (cid:52) ‘ ( v ) ⊆ cl (cid:52) ‘ ( u ) } for all cl (cid:52) ‘ ( u ) ∈ Q, a ∈ Σ . (cid:73) Lemma 6.
Let L ⊆ Σ ∗ be a language and let (cid:52) ‘ be a left L -preserving quasiorder. Then H ‘ ( (cid:52) ‘ , L ) is a co-RFA such that L ( H ‘ ( (cid:52) ‘ , L )) = L . Observe that the automaton H r = H r ( (cid:52) r , L ) (resp. H ‘ = H ‘ ( (cid:52) ‘ , L )) is finite , since weassume (cid:52) r (resp. (cid:52) ‘ ) induces a finite number of principals. Note also that H r (resp. H ‘ )possibly contains empty (resp. unreachable) states but no state is unreachable (resp. empty).Moreover, notice that by keeping all principals of (cid:52) r (resp. (cid:52) ‘ ) as states, instead of onlythe prime ones as in Definition 3 (resp. Definition 5), we would obtain an RFA (resp. aco-RFA) with (possibly) more states that also recognizes L .The following lemma shows that H r and H ‘ inherit the left-right duality between (cid:52) r and (cid:52) ‘ through the reverse operation. (cid:73) Lemma 7.
Let (cid:52) r and (cid:52) ‘ be a right and a left quasiorder, respectively, and let L ⊆ Σ ∗ bea language. If u (cid:52) r v ⇔ u R (cid:52) ‘ v R then H r ( (cid:52) r , L ) is isomorphic to (cid:0) H ‘ ( (cid:52) ‘ , L R ) (cid:1) R . Finally, it follows from the next theorem that given two right L -preserving quasiorders, (cid:52) r and (cid:52) r , if (cid:52) r ⊆ (cid:52) r then the automaton H r ( (cid:52) r , L ) has, at least, as many states as H r ( (cid:52) r , L ). The same holds for left L -preserving quasiorders and H ‘ . Observe that this is notobvious since only the L -prime principals correspond to states of the automata construction. (cid:73) Theorem 8.
Let L ⊆ Σ ∗ be a language and let (cid:52) and (cid:52) be two left or two right L -preserving quasiorders. If (cid:52) ⊆ (cid:52) then: |{ cl (cid:52) ( u ) | u ∈ Σ ∗ ∧ cl (cid:52) ( u ) is L -prime }| ≥ |{ cl (cid:52) ( u ) | u ∈ Σ ∗ ∧ cl (cid:52) ( u ) is L -prime }| . A Quasiorder-based Perspective on Residual Automata
In this section we instantiate our automata constructions using two classes of quasiorders,namely, the so-called
Nerode’s quasiorders [6], whose definition is based on a given regularlanguage; and the automata-based quasiorders, whose definition relies on a given automaton. (cid:73)
Definition 9 (Language-based Quasiorders) . Let u, v ∈ Σ ∗ and let L ⊆ Σ ∗ be a language.Define: u (cid:52) rL v def ⇐⇒ u − L ⊆ v − L Right- language-based Quasiorder (1) u (cid:52) ‘L v def ⇐⇒ Lu − ⊆ Lv − Left- language-based Quasiorder (2)It is well-known that for every regular language L there exists a finite number of quotients u − L [7] . Therefore, the language-based quasiorders defined above induce a finite numberof principals since each principal set is determined by a quotient of L . (cid:73) Definition 10 (Automata-based Quasiorders) . Let u, v ∈ Σ ∗ and let N = ( Q, Σ , δ, I, F ) bean NFA. Define: u (cid:52) r N v def ⇐⇒ post N u ( I ) ⊆ post N v ( I ) Right- Automata-based Quasiorder (3) u (cid:52) ‘ N v def ⇐⇒ pre N u ( F ) ⊆ pre N v ( F ) Left- Automata-based Quasiorder (4)Clearly, the automata-based quasiorders induce a finite number of principals since eachprincipal is represented by a subset of the states of N . (cid:73) Remark 11.
The pairs of quasiorders (cid:52) rL - (cid:52) ‘L and (cid:52) r N - (cid:52) ‘ N from Definitions 9 and 10 aredual, i.e. u (cid:52) rL v ⇔ u R (cid:52) ‘L v R and u (cid:52) r N v ⇔ u R (cid:52) ‘ N v R .The following result shows that the principals of (cid:52) r N and (cid:52) ‘ N can be described, respectively,as intersections of left and right languages of the states of N while the principals of (cid:52) rL and (cid:52) ‘L correspond to intersections of quotients of L . (cid:73) Lemma 12.
Let N = ( Q, Σ , δ, I, F ) be an NFA with L ( N ) = L . Then, for every u ∈ Σ ∗ , cl (cid:52) r N ( u ) = \ q ∈ post N u ( I ) W N I,q cl (cid:52) rL ( u ) = \ w ∈ Σ ∗ , w ∈ u − L Lw − cl (cid:52) ‘ N ( u ) = \ q ∈ pre N u ( I ) W N q,F cl (cid:52) ‘L ( u ) = \ w ∈ Σ ∗ , w ∈ Lu − w − L .
As shown by Ganty et al. [12], given an NFA N with L = L ( N ), the quasiorders (cid:52) rL and (cid:52) r N are right L -preserving quasiorders, while the quasiorders (cid:52) ‘L and (cid:52) ‘ N are left L -preservingquasiorders. Therefore, by Lemma 4 and 6, our automata constructions applied to thesequasiorders yield automata for L .Finally, as shown by de Luca and Varricchio [6], we have that (cid:52) r N is finer than (cid:52) rL , i.e., (cid:52) r N ⊆ (cid:52) rL . In that sense we say that (cid:52) r N approximates (cid:52) rL . As the following lemma shows,the approximation is precise, i.e., (cid:52) r N = (cid:52) rL , whenever N is a co-RFA with no empty states. (cid:73) Lemma 13.
Let N be a co-RFA with no empty states such that L = L ( N ) . Then (cid:52) rL = (cid:52) r N .Similarly, if N is an RFA with no unreachable states and L = L ( N ) then (cid:52) ‘L = (cid:52) ‘ N . In what follows, we will use
Can r , Can ‘ and Res r , Res ‘ to denote the constructions H r , H ‘ when applied, respectively, to the language-based quasiorders induced by a regular languageand the automata-based quasiorders induced by an NFA. . Ganty and E. Gutiérrez and P. Valero 7 N Res ‘ ( N ) Can r ( L ( N )) N R Res r ( N R ) Res ‘ ( Res r ( N R )) R Res ‘ Can r R Res r R Res r Can ‘ Res ‘ The upper part of the diagram follows from The-orem 15 (f), the squares follow from Theorem 15 (c)and the bottom curved arc follows from The-orem 15 (b). Incidentally, the diagram shows a newrelation which is a consequence of the left-rightdualities between (cid:52) ‘L and (cid:52) rL , and (cid:52) ‘ N and (cid:52) r N : Can ‘ ( L ( N R )) is isomorphic to Res ‘ ( Res r ( N R )). Figure 1
Relations between the constructions
Res ‘ , Res r , Can ‘ and Can r . Note that constructions Can r and Can ‘ are applied to the language accepted by the automaton in the origin of the labeledarrow while constructions Res r and Res ‘ are applied directly to the automaton. (cid:73) Definition 14.
Let N be an NFA accepting the language L = L ( N ) . Define: Can r ( L ) def = H r ( (cid:52) rL , L ) Res r ( N ) def = H r ( (cid:52) r N , L ) Can ‘ ( L ) def = H ‘ ( (cid:52) ‘L , L ) Res ‘ ( N ) def = H ‘ ( (cid:52) ‘ N , L ) . Given an NFA N accepting the language L = L ( N ), all constructions in the abovedefinition yield automata accepting L . However, while the constructions using the rightquasiorders result in RFAs, those using left quasiorders result in co-RFAs. Furthermore,it follows from Remark 11 and Lemma 7 that Can ‘ ( L ) is isomorphic to ( Can r ( L R )) R and Res ‘ ( N ) is isomorphic to ( Res r ( N R )) R .It follows from Theorem 8 that the automata Res r ( N ) and Res ‘ ( N ) have more statesthan Can r ( L ) and Can ‘ ( L ), respectively. Intuitively, Can r ( L ) is the minimal RFA for L , i.e.it is isomorphic to the canonical RFA for L , since (cid:52) rL is the coarsest right L -preservingquasiorder [6]. On the other hand, as we evidenced in Example 17, Res r ( N ) is a sub-automaton of N res [9] for every NFA N .Finally, it follows from Lemma 13 that residualizing ( Res r ) a co-RFA with no emptystates ( Res ‘ ( N )) results in the canonical RFA for L ( N ) ( Can r ( L ( N ))).We formalize all these notions in Theorem 15. Figure 1 summarizes all these connectionsbetween the automata constructions given in Definition 14. (cid:73) Theorem 15.
Let N be an NFA with L = L ( N ) . Then the following properties hold: (a) L ( Can r ( L )) = L ( Can ‘ ( L )) = L = L ( Res r ( N )) = L ( Res ‘ ( N )) . (b) Can ‘ ( L ) is isomorphic to ( Can r ( L R )) R . (c) Res ‘ ( N ) is isomorphic to ( Res r ( N R )) R . (d) Can r ( L ) is isomorphic to the canonical RFA for L . (e) Res r ( N ) is isomorphic to a sub-automaton of N res and L ( Res r ( N )) = L ( N res ) = L . (f) Res r ( Res ‘ ( N )) is isomorphic to Can r ( L ) . Let N be an NFA with L = L ( N ). If (cid:52) rL = (cid:52) r N then the automata Can r ( L ) and Res r ( N )are isomorphic. The following result shows that the reverse implication also holds. (cid:73) Lemma 16.
Let N be an NFA with L = L ( N ) . Then (cid:52) rL = (cid:52) r N iff Res r ( N ) is isomorphicto Can r ( L ( N )) . The following example illustrates the differences between our residualization operation,
Res r ( N ), and the one defined by Denis et al. [9], N res , on a given NFA N : the automaton Res r ( N ) has, at most, as many states as N res . This follows from the fact that for every u ∈ Σ ∗ , if post N u ( I ) is coverable then cl (cid:52) r N ( u ) is composite but not vice-versa. A Quasiorder-based Perspective on Residual Automata a, b, c a, cb, cc abca, b, c { } { , , , }{ , }{ , } { } a, c cb, c a, ba, b, ca, c cl( ε ) cl( a )cl( b ) cl( aa ) a, c b, c a, ba, c Figure 2
An NFA N and the RFAs N res and Res r ( N ). We omit the empty states for clarity. (cid:73) Example 17.
Let N = ( Q, Σ , δ, I, F ) be the automata on the left of Figure 2 and let L = L ( N ). To build N res we compute post N u ( I ), for all u ∈ Σ ∗ . Let C def = L c \ { ε, a, b, c } .post N ε ( I ) = { } post N a ( I ) = { , } ∀ w ∈ L, post N w ( I ) = { } post N c ( I ) = { , , , } post N b ( I ) = { , } ∀ w ∈ C, post N w ( I ) = ∅ Since none of these sets is coverable by the others, they are all states of N res . The resultingRFA N res is shown in the center of Figure 2. On the other hand, let us denote cl (cid:52) r N simplyby cl. In order to build Res r ( N ) we need to compute the principals cl( u ), for all u ∈ Σ ∗ . Bydefinition of (cid:52) r N , we have that w ∈ cl( u ) ⇔ post N u ( I ) ⊆ post N w ( I ). Therefore, we obtain:cl( ε )= { ε } cl( a )= { a, c } cl( b )= { b, c } cl( c )= { c } ∀ w ∈ L, cl( w )= L ∀ w ∈ C, cl( w )=Σ ∗ . Since a ≺ r N c , b ≺ r N c and ∀ w ∈ Σ ∗ , cw ⊆ L ⇔ (cid:0) aw ⊆ L ∨ bw ⊆ L (cid:1) , it follows that cl( c ) is L -composite. The resulting RFA Res r ( N ) is shown on the right of Figure 2. ♦ Denis et al. [9] show that their residualization operation satisfies the residual-equivalent ofthe double-reversal method for building the minimal DFA. More specifically, they provethat if an NFA N is a co-RFA with no empty states, then their residualization operationapplied to N results in the canonical RFA for L ( N ). As a consequence, ((( N R ) res ) R ) res isthe canonical RFA for L ( N ).In this section we first show that the residual-equivalent of the double-reversal methodholds within our framework, i.e. Res r (( Res r ( N R )) R ) is isomorphic to Can r ( N ). Then, wegeneralize this method along the lines of the generalization of the double-reversal method forbuilding the minimal DFA given by Brzozowski and Tamm [5]. To this end, we extend ourprevious work [11] in which we provided a congruence-based perspective on the generalizeddouble-reversal method for DFAs. By moving from congruences to quasiorders, we find a necessary and sufficient condition on an NFA N so that Res r ( N ) yields the canonical RFAfor L ( N ). Finally, we compare our generalization with the one given by Tamm [15]. We give a simple proof of the double-reversal method for building the canonical RFA. (cid:73)
Theorem 18 (Double-Reversal) . Let N be an NFA. Then Res r (( Res r ( N R )) R ) is isomorphicto the canonical RFA for L ( N ) . Proof.
It follows from Theorem 15 (c), (d) and (f). (cid:74) . Ganty and E. Gutiérrez and P. Valero 9
Note that Theorem 18 can be inferred from Figure 1 by following the path starting at N ,labeled with R − Res r − R − Res r and ending in Can r ( L ( N )). Next we show that residualizing an automaton yields the canonical RFA iff the left languageof every state is closed w.r.t. the right Nerode quasiorder. (cid:73)
Theorem 19.
Let N = ( Q, Σ , δ, I, F ) be an NFA with L = L ( N ) . Then Res r ( N ) is thecanonical RFA for L iff ∀ q ∈ Q, cl (cid:52) rL ( W N I,q ) = W N I,q . Proof.
We first show that ∀ q ∈ Q, cl (cid:52) rL ( W N I,q ) = W N I,q is a necessary condition, i.e. if
Res r ( N )is the canonical RFA for L then ∀ q ∈ Q, cl (cid:52) rL ( W N I,q ) = W N I,q holds. By Lemma 16 we havethat if
Res r ( N ) is the canonical RFA then (cid:52) rL = (cid:52) r N . Moreover,cl (cid:52) rL ( W N I,q ) = [By definition of cl (cid:52) rL ] { w ∈ Σ ∗ | ∃ u ∈ W N I,q , u − L ⊆ w − L } = [Since (cid:52) rL = (cid:52) r N ] { w ∈ Σ ∗ | ∃ u ∈ W N I,q , post N u ( I ) ⊆ post N w ( I ) } ⊆ [Since u ∈ W N I,q ⇔ q ∈ post N u ( I )] { w ∈ Σ ∗ | q ∈ post N w ( I ) } = [By definition of W N I,q ] W N I,q . By reflexivity of (cid:52) rL , we conclude that cl (cid:52) rL ( W N I,q ) = W N I,q .Next, we show that ∀ q ∈ Q, cl (cid:52) rL ( W N I,q ) = W N I,q is also a sufficient condition. ByLemma 12 and condition ∀ q ∈ Q, cl (cid:52) rL ( W N I,q ) = W N I,q , we have thatcl (cid:52) r N ( u ) = \ q ∈ post N u ( I ) W N I,q = \ q ∈ post N u ( I ) cl (cid:52) rL ( W N I,q ) . Since u ∈ cl (cid:52) rL ( W N I,q ) for all q ∈ post N u ( I ), it follows that cl (cid:52) rL ( u ) ⊆ cl (cid:52) rL ( W N I,q ) for all q ∈ post N u ( I ) and, since cl (cid:52) r N ( u ) = T q ∈ post N u ( I ) cl (cid:52) rL ( W N I,q ), we have that cl (cid:52) rL ( u ) ⊆ cl (cid:52) r N ( u )for every u ∈ Σ ∗ , i.e., (cid:52) rL ⊆ (cid:52) r N .On the other hand, as shown by de Luca and Varricchio [6], we have that (cid:52) r N ⊆ (cid:52) rL . Weconclude that (cid:52) r N = (cid:52) rL , hence Res r ( N ) = Can r ( L ). (cid:74) It is worth to remark that Theorem 19 does not hold when considering the residualizationoperation N res of Denis et al. [9] instead of Res r ( N ). As a counterexample we have theautomata N in Figure 2 where Res r ( N ) is the canonical RFA for L ( N ), hence N satisfiesthe condition of Theorem 19, while N res is not canonical. Co-atoms and co-rests
The condition of Theorem 19 is analogue to the one we gave for building the minimal DFA [11],except that the later is formulated in terms of congruences instead of quasiorders. In that casewe proved that determinizing a given NFA N yields the minimal DFA iff cl ∼ rL ( W N I,q ) = W N I,q for every state q of N , where ∼ rL def = (cid:52) rL ∩ ( (cid:52) rL ) − is the right Nerode’s congruence [7].Moreover, we showed that the principals of ∼ rL coincide with the so-called co-atoms [11],which are non-empty intersections of complemented and uncomplemented right quotients ofthe language. This allowed us to connect our result for DFAs [11] with the generalizationof the double-reversal method for building the minimal DFA proposed by Brzozowski andTamm [5], who establish that determinizing an NFA N yields the minimal DFA for L ( N ) iffthe left languages of the states of N are unions of co-atoms of L ( N ). Next, we give a formulation of the condition from Theorem 19 along the lines of the onegiven by Brzozowski and Tamm [5] for their generalization of the double-reversal method forbuilding the minimal DFA.To do that, let us call the intersections used in Lemma 12 to describe the principals of (cid:52) ‘L and (cid:52) rL as rests and co-rests of L , respectively. As shown by Theorem 19, residualizing anNFA N yields the canonical RFA for L ( N ) iff the left language of every state of N satisfiescl (cid:52) rL ( W N I,q ) = W N I,q . By definition, cl (cid:52) rL ( S ) = S iff S is a union of principals of (cid:52) rL which, byLemma 12 are the co-rests of L .Therefore we derive the following statement, equivalent to Theorem 19, that we consideras the residual-equivalent of the generalization of the double-reversal method for buildingthe minimal DFA proposed by Brzozowski and Tamm [5]. (cid:73) Corollary 20.
Let N = ( Q, Σ , δ, I, F ) be an NFA with L = L ( N ) . Then Res r ( N ) is thecanonical RFA for L iff the left languages of N are union of co-rests. Tamm’s Generalization of the Double-reversal Method for RFAs
Tamm [15] generalized the double-reversal method of Denis et al. [9] by showing that N res isthe canonical RFA for L ( N ) iff the left languages of N are union of the left languages of thecanonical RFA for L ( N ).In this section, we compare the generalization of Tamm [15] with ours. The two approachesdiffer in the definition of the residualization operation they consider and, as the followinglemma shows, the sufficient and necessary condition from Theorem 19 is more general thanthat of Tamm [15, Theorem 4] (cid:73) Lemma 21.
Let N = ( Q, Σ , δ, I, F ) be an NFA and let C = Can r ( (cid:52) rL , L ) = ( e Q, Σ , e δ, e I, e F ) be the canonical RFA for L = L ( N ) . If W N I,q = S q ∈ e Q W C e I,q then cl (cid:52) rL ( W N I,q ) = W N I,q . Proof.
Since the canonical RFA, C , is strongly consistent, it follows from Lemma 34 (seeAppendix B) that (cid:52) r C = (cid:52) rL and, consequently, Res r ( C ) is isomorphic to Can r ( L ). It followsfrom Theorem 19 that cl (cid:52) rL ( W C e I,q ) = W C e I,q for every q ∈ e Q . Therefore,cl (cid:52) rL ( W N I,q ) = [Since W N I,q = S q ∈ e Q W C e I,q and cl (cid:52) rL ( ∪ S i ) = ∪ cl (cid:52) rL ( S i )] S q ∈ e Q cl (cid:52) rL ( W C e I,q ) = [Since cl (cid:52) rL ( W C e I,q ) = W C e I,q for every q ∈ e Q ] S q ∈ e Q W C e I,q . (cid:74) Observe that, since the canonical RFA C = ( e Q, Σ , e δ, e I, e F ) for a language L is stronglyconsistent , the left language of each state is a principal of cl (cid:52) rL . In particular, if the rightlanguage of a state is u − L then its left language is the principal cl (cid:52) rL ( u ). Therefore, if W N I,q = S q ∈ e Q W C e I,q then W N I,q is a closed set in cl (cid:52) rL . However, the reverse implication doesnot hold since only the L -prime principals are left languages of states of C .On the other hand, L -composite principals for (cid:52) rL can be described as intersections of L -prime principals (see Lemma 35 in Appendix B). As a consequence, Res r ( N ) is isomorphicto C iff the left languages of states of N are union of non-empty intersections of left languagesof C , while, as shown by Tamm [15], N res is isomorphic to C iff the left languages of thestates of N are union of left languages of C . . Ganty and E. Gutiérrez and P. Valero 11 Bollig et al. [3] devised the NL ∗ algorithm for learning the canonical RFA for a given regularlanguage. The algorithm describes the behavior of a Learner that infers a language L byperforming membership queries on L (which are answered by a Teacher ) and equivalencequeries between the language accepted by a candidate automaton and L (which are answeredby an Oracle ). The algorithm terminates when the
Learner builds an RFA accepting thelanguage L . Appendix A contains a formal description of the NL ∗ algorithm.In this section we present a quasiorder-based perspective on the NL ∗ algorithm in whichthe Learner iteratively refines a quasiorder (cid:52) on Σ ∗ by querying the Teacher and uses anadaption of the automata construction H r ( (cid:52) , L ) from Definition 3 to build an automatonthat is used to query the Oracle . We capture this approach in the so-called NL (cid:52) algorithm whose pseudocode we defer to Appendix B. Here we give the definitions and general steps ofthe NL (cid:52) algorithm.The Learner maintains a prefix-closed finite set
P ⊆ Σ ∗ and a suffix-closed finite set S ⊆ Σ ∗ . The set S is used to approximate the principals in (cid:52) rL for the words in P . In orderto manipulate these approximations, we define the following two operators. (cid:73) Definition 22.
Let L be a language, S ⊆ Σ ∗ and u, v ∈ Σ ∗ . Then u − L = S v − L def ⇐⇒ (cid:0) u − L ∩ S (cid:1) = (cid:0) v − L ∩ S (cid:1) . Similarly, u − L ⊆ S v − L def ⇐⇒ (cid:0) u − L ∩ S (cid:1) ⊆ (cid:0) v − L ∩ S (cid:1) . These operators allow us to define a version of Nerode’s quasiorder restricted to S . (cid:73) Definition 23 (Right-language-based quasiorder w.r.t. S ) . Let L be a language, S ⊆ Σ ∗ and u, v ∈ Σ ∗ . Define u (cid:52) rL S v def ⇐⇒ u − L ⊆ S v − L . Recall that the
Learner only manipulates the principals for the words in P . Therefore,we need to adapt the notion of composite principal for (cid:52) rL S . (cid:73) Definition 24 ( L S -Composite Principal w.r.t. P ) . Let P , S ⊆ Σ ∗ with u ∈ P and let L ⊆ Σ ∗ be a language. We say that the principal cl (cid:52) rL S ( u ) is L S -composite w.r.t. P iff u − L = S S x ∈P , x ≺ rL S u x − L . Otherwise, we say it is L S - prime w.r.t. P . The
Learner uses the quasiorder (cid:52) rL S to build an automaton by adapting the constructionfrom Definition 3 in order to use only the information that is available by means of the sets S and P . Building such an automaton requires the quasiorder to satisfy two conditions: itmust be closed and consistent w.r.t. P . (cid:73) Definition 25 (Closedness and Consistency of (cid:52) rL S w.r.t. P ) .(a) (cid:52) rL S is closed w.r.t. P iff ∀ u ∈ P , a ∈ Σ , cl (cid:52) rL S ( ua ) is L S -prime w.r.t. P ⇒ ∃ v ∈ P , cl (cid:52) rL S ( ua ) = cl (cid:52) rL S ( v ) . (b) (cid:52) rL S is consistent w.r.t. P iff ∀ u, v ∈ P , a ∈ Σ : u (cid:52) rL S v ⇒ ua (cid:52) rL S va . At each iteration, the
Learner checks whether the quasiorder (cid:52) rL S is closed and consistentw.r.t. P . If (cid:52) rL S is not closed w.r.t. P , then it finds cl (cid:52) rL S ( ua ) with u ∈ P , a ∈ Σ such thatcl (cid:52) rL S ( ua ) is L S -prime w.r.t. P and it is not equal to some cl (cid:52) rL S ( v ) with v ∈ P . Then the Learner adds ua to P .Similarly, if (cid:52) rL S is not consistent w.r.t. P , the Learner finds u, v ∈ P , a ∈ Σ , x ∈ S suchthat u (cid:52) rL S v but uax ∈ L ∧ vax / ∈ L . Then the Learner adds ax to S . When the quasiorder (cid:52) rL S is closed and consistent w.r.t. P , the Learner builds the automaton R ( (cid:52) rL S , P ).Definition 26 is an adaptation of the automata construction H r from Definition 3. Insteadof considering all principals, it considers only those that correspond to words in P . Moreover, the notion of L -primality is replaced by L S -primality w.r.t. P , since the algorithm does notmanipulate quotients of L by words in Σ ∗ but the approximation through S of the quotientsof L by words in P (see Definition 22). Note that, if S = P = Σ ∗ then Can r ( L ) = R ( (cid:52) rL S , P ). (cid:73) Definition 26 (Automata construction R ( (cid:52) rL S , P ) ) . Let L ⊆ Σ ∗ be a language and let P , S ⊆ Σ ∗ . Define the automaton R ( (cid:52) rL S , P ) = ( Q, Σ , δ, I, F ) with Q = { cl (cid:52) rL S ( u ) | u ∈ P , cl (cid:52) rL S ( u ) is L S -prime w.r.t. P} , I = { cl (cid:52) rL S ( u ) ∈ Q | ε ∈ cl (cid:52) rL S ( u ) } , F = { cl (cid:52) rL S ( u ) ∈ Q | u ∈ L } and δ (cl (cid:52) rL S ( u ) , a ) = { cl (cid:52) rL S ( v ) ∈ Q | cl (cid:52) rL S ( u ) a ⊆ cl (cid:52) rL S ( v ) } for all cl (cid:52) rL S ( u ) ∈ Q and a ∈ Σ . Finally, the
Learner asks the
Oracle whether L ( R ( (cid:52) rL S , P )) = L . If the Oracle answers yes then the algorithm terminates. Otherwise, the
Oracle returns a counterexample w for thelanguage equivalence. Then, the Learner adds every suffix of w to S and repeats the process.Theorem 27 shows that the NL (cid:52) algorithm exactly coincides with NL ∗ . (cid:73) Theorem 27. NL (cid:52) builds the same sets P and S , performs the same queries to the Oracle and the
Teacher and returns the same RFA as NL ∗ , provided that both algorithms resolvenondeterminism the same way. It is worth to remark that, by replacing the right quasiorder (cid:52) rL S by the right congruence ∼ L S def = (cid:52) rL S ∩ ( (cid:52) rL S ) − in the above algorithm (precisely, in Definitions 25 and 26), theresulting algorithm corresponds to Angluin’s L ∗ algorithm [2]. Note that, in that case, allprincipals cl ∼ L S ( u ), with u ∈ Σ ∗ , are L S -prime w.r.t. P . Denis et al. [9] introduced the notion of RFA and canonical RFA for a language and deviseda procedure, similar to the subset construction for DFAs, to build the RFA N res from a givenautomaton N . Furthermore, they showed that N res is isomorphic to the canonical RFA C for L ( N ) when N is a co-RFA with no empty states. Later, Tamm [15] showed that N res is isomorphic to C iff the left language of every state of N is a union of left languages ofstates of C . This result generalizes the double-reversal method for building the canonicalRFA along the lines of the generalization by Brzozowski and Tamm [5] of the double-reversalmethod for DFAs, which claims that determinizing an automaton N yields the minimal DFAiff the left language of each state of N is a union of co-atoms of L ( N ). Although the twogeneralizations have a common foundation, the connection between the two results is notimmediate.Recently [11], we offered a congruence-based perspective of the generalized double-reversalmethod for DFAs and showed that determinizing an NFA, N , yields the minimal DFA for L ( N )iff cl ∼ rL ( W N I,q ) = W N I,q . In this paper we extend our previous work and devise quasiorder-basedautomata constructions that result in RFAs. One of these constructions, when instantiatedwith the automata-based quasiorder from Definition 10, defines a residualization operationthat, given an NFA N , produces the RFA Res r ( N ) with, at most, as many states as N res ,the residualization operation defined by Denis et al. [9]. Observe that if N is a co-RFA withno empty states then both N res and Res r ( N ) are isomorphic to C .On the other hand, Theorem 19 shows that Res r ( N ) is isomorphic to C iffcl (cid:52) rL ( W N I,q ) = W N I,q . We believe that the similarity between the generalizations of thedouble-reversal methods for DFAs (cl ∼ rL ( W N I,q ) = W N I,q ) and for RFAs (cl (cid:52) rL ( W N I,q ) = W N I,q )evidences that quasiorders are for RFAs as congruences are for DFAs. Indeed, determinizingan NFA N with L = L ( N ) yields the minimal DFA for L iff ∼ r N = ∼ rL [11] and, similarly, . Ganty and E. Gutiérrez and P. Valero 13 Brzozowski and Tamm [5]
Ganty et al. [11] N D ≡ M iff ∀ q, W N I,q is a union of co-atoms N D ≡ M iff ∀ q, cl ∼ rL ( W N I,q ) = W N I,q
Tamm [15] Theorem 19 N res ≡ C iff ∀ q, W N I,q is a union of W C I,q Res r ( N ) ≡ C iff ∀ q, cl (cid:52) rL ( W N I,q ) = W N I,q
In the diagram: N is an NFAwith L = L ( N ); N D is theresult of determinizing N withthe standard subset construc-tion; M is the minimal DFA for L ; C = Can r ( L ) is the canon-ical RFA for L and N ≡ N denotes that automaton N isisomorphic to N . Figure 3
Summary of the existing results about the generalized double-reversal method forbuilding the minimal DFA (first row) and the canonical RFA (second row) for a given language. Theresults on the first column are based on the notion of atoms of a language while the results on thesecond column are based on quasiorders . when residualizing N with our residualization operation we obtain the canonical RFA for L iff (cid:52) r N = (cid:52) rL , as shown by Lemma 16.It is worth to remark that the left languages of the minimal DFA for L are principals of ∼ rL [11]. Therefore, the condition cl ∼ rL ( W N I,q ) = W N I,q , which guarantees that determinizing N yields the minimal DFA, can be stated as: the left language of each state of N is a union ofleft languages of states of the minimal DFA . Thus, this characterization is the DFA-equivalentof Tamm’s condition [15] for RFAs.Figure 3 summarizes the existing results about these double-reversal methods.Moreover, we support the idea that quasiorders are natural to residual automata byobserving that the NL ∗ algorithm can be interpreted as an algorithm that, at each iteration,refines an approximation of the Nerode’s quasiorder and builds an RFA using our automataconstruction.Finally, it is worth to mention that Myers et al. [14] describe different canonical non-determinism automata constructions for a given regular language and show how to obtain thecanonical RFA. They do it by first constructing the minimal DFA for the language interpretedin a variety of join-semilattices and then applying a dual equivalence between this variety andthe category of closure spaces. In some sense, this already establishes a connection betweenthe class of DFAs and RFAs. Indeed, the same authors [1] use this category-theoreticalperspective to address the residual-equivalent of the double-reversal method proposed byDenis et al. [9]. In contrast, this work revisit different methods to construct the canonicalRFA relying on the simple notion of quasiorders on words, as a natural extension of our workon congruences for the study of minimization techniques for DFAs. References Jirí Adámek, Robert S. R. Myers, Henning Urbat, and Stefan Milius. On continuous non-determinism and state minimality. In
MFPS , volume 308 of
Electronic Notes in TheoreticalComputer Science , pages 3–23. Elsevier, 2014. Dana Angluin. Learning regular sets from queries and counterexamples.
Inf. Comput. ,75(2):87–106, 1987. Benedikt Bollig, Peter Habermehl, Carsten Kern, and Martin Leucker. Angluin-style learningof NFA. In
IJCAI , pages 1004–1009, 2009. Janusz A. Brzozowski. Canonical regular expressions and minimal state graphs for definiteevents.
Mathematical Theory of Automata , 12(6):529–561, 1962. Janusz A. Brzozowski and Hellis Tamm. Theory of átomata.
Theor. Comput. Sci. , 539:13–27,2014. Aldo de Luca and Stefano Varricchio. Well quasi-orders and regular languages.
Acta Inf. ,31(6):539–557, 1994. Aldo de Luca and Stefano Varricchio.
Finiteness and Regularity in Semigroups and FormalLanguages . Monographs in Theoretical Computer Science. An EATCS Series. Springer, 1999. François Denis, Aurélien Lemay, and Alain Terlutte. Learning regular languages using nondeterministic finite automata. In
ICGI , volume 1891 of
Lecture Notes in Computer Science ,pages 39–50. Springer, 2000. François Denis, Aurélien Lemay, and Alain Terlutte. Residual finite state automata.
Fundam.Inform. , 51(4):339–368, 2002. François Denis, Aurélien Lemay, and Alain Terlutte. Learning regular languages using RFSAs.
Theor. Comput. Sci. , 313(2):267–294, 2004. Pierre Ganty, Elena Gutiérrez, and Pedro Valero. A congruence-based perspective on automataminimization algorithms. In
MFCS , volume 138 of
LIPIcs , pages 77:1–77:14. Schloss Dagstuhl- Leibniz-Zentrum für Informatik, 2019. Pierre Ganty, Francesco Ranzato, and Pedro Valero. Language inclusion algorithms as completeabstract interpretations. In
SAS , volume 11822 of
Lecture Notes in Computer Science , pages140–161. Springer, 2019. Anna Kasprzik. Inference of residual finite-state tree automata from membership queries andfinite positive data. In
Developments in Language Theory , volume 6795 of
Lecture Notes inComputer Science , pages 476–477. Springer, 2011. Robert S. R. Myers, Jirí Adámek, Stefan Milius, and Henning Urbat. Coalgebraic constructionsof canonical nondeterministic automata.
Theor. Comput. Sci. , 604:81–101, 2015. Hellis Tamm. Generalization of the double-reversal method of finding a canonical residualfinite state automaton. In
DCFS , volume 9118 of
Lecture Notes in Computer Science , pages268–279. Springer, 2015.
A Learning Algorithm NL ∗ Bollig et al. [3] devised an algorithm, NL ∗ , that learns the canonical RFA for a given regularlanguage L . Similarly to the well-known L ∗ algorithm of Angluin [2], the NL ∗ algorithmrelies on a Teacher , which answers membership queries for L , and an Oracle which answersequivalence queries between the language accepted by an RFA and L .The Learner maintains a prefix-closed finite set
P ⊆ Σ ∗ and a suffix-closed finite set S ⊆ Σ ∗ . The Learner groups the words in P by building a table T = ( T , P , S ) where T : ( P ∪ P Σ) × S → { + , −} is a function such that for every u ∈ P ∪ P Σ and v ∈ S we havethat T ( u, v ) = + ⇔ uv ∈ L . Otherwise T ( u, v ) = − . For every word u ∈ P ∪ P Σ, define thefunction r( u ) : S → { + , −} as r( u )( v ) def = T ( u, v ). The set of all rows of a table T is denotedby Rows( T ).The algorithm uses the table T = ( T, P , S ) to build an automaton whose states are someof the rows T . In order to do that, it is necessary to define the notions of union of rows, prime row and composite row. (cid:73) Definition 28 (Join Operator) . Let T = ( T, P , S ) be a table. For every r , r ∈ Rows( T ) ,define the join r t r : S → { + , −} as: ∀ x ∈ S , ( r t r )( x ) def = (cid:26) + if r ( x ) = + ∨ r ( x ) = + − otherwise Note that the join operator is associative, commutative and idempotent. However, thejoin of two rows is not necessarily a row of T . . Ganty and E. Gutiérrez and P. Valero 15 (cid:73) Definition 29 (Covering Relation) . Let T = ( T, P , S ) be a table. Then, for every pair ofrows r , r ∈ Rows( T ) we have that r v r def ⇐⇒ ∀ x ∈ S , r ( x ) = + ⇒ r ( x ) = + . Wewrite r (cid:64) r to denote r v r and r = r . (cid:73) Definition 30 (Composite and Prime Rows) . Let T = ( T, P , S ) be a table. We say a row r ∈ Rows( T ) is T - composite if it is the join of all the rows that it strictly covers, i.e., r = F r ∈ Rows( T ) , r (cid:64) r r . Otherwise, we say r is T - prime . (cid:73) Definition 31 (Closed and Consistent Table) . Let T = ( T, P , S ) be a table. Then (a) T is closed if ∀ u ∈ P , a ∈ Σ , r( ua ) = F { r( v ) | v ∈ P , r( v ) v r( ua ) ∧ r( v ) is T -prime } . (b) T is consistent if r( u ) v r( v ) ⇒ r( ua ) v r( va ) for every u, v ∈ P and a ∈ Σ . At each iteration of the algorithm, the
Learner checks whether the table T = ( T, P , S ) isclosed and consistent. If T is not closed, then it finds r( ua ) with u ∈ P , a ∈ Σ such that r( ua )is T -prime and it is not equal to some r( v ) with v ∈ P . Then the Learner adds ua to P andupdates the table T . Similarly, if T is not consistent, the Learner finds u, v ∈ P , a ∈ Σ , x ∈ S such that r( u ) ⊆ r( v ) but r( ua )( x ) = + ∧ r( va )( x ) = − . Then the Learner adds ax to S andupdates T . When the table T is closed and consistent, the Learner builds the RFA R ( T ). (cid:73) Definition 32 ( R ( T ) ) . Let T = ( T, P , S ) be a table. Define the automaton R ( T ) =( Q, Σ , I, F, δ ) with Q = { r( u ) | u ∈ P ∧ r( u ) is T -prime } , I = { r( u ) ∈ Q | r( u ) v r( ε ) } , F = { r( u ) ∈ Q | r( u )( ε ) = + } and r( v ) ∈ δ (r( u ) , a ) = { r( v ) ∈ Q | r( v ) v r( ua ) } for all r( u ) ∈ Q, a ∈ Σ . The
Learner asks the
Oracle whether L ( R ( T )) = L . If the Oracle answers yes then thealgorithm terminates. Otherwise, the
Oracle returns a counterexample w for the languageequivalence. Then the Learner adds every suffix of w to S , updates the table T and repeatsthe process. B Supplementary Results
In this section we include auxiliary results that we refer to in the main part of the documentand/or we use in the deferred proofs.The following result establishes a relationship between the L -composite principals fortwo comparable right quasiorders (cid:52) r ⊆ (cid:52) r . This result is used in Theorem 8 to show thatthe number of L -prime principals induced by (cid:52) r is greater than or equal to the number of L -prime principals induced by (cid:52) r . (cid:73) Lemma 33.
Let L ⊆ Σ ∗ be a regular language and let u ∈ Σ ∗ . Let (cid:52) r and (cid:52) r be two right L -preserving quasiorders such that (cid:52) r ⊆ (cid:52) r . Then cl (cid:52) r ( u ) is L -composite ⇒ (cid:0) cl (cid:52) r ( u ) is L -composite ∨ ∃ x ≺ r u, cl (cid:52) r ( u ) = cl (cid:52) r ( x ) (cid:1) . Similarly holds for left L -preserving quasiorders. Proof.
Let u ∈ Σ ∗ be such that cl (cid:52) r ( u ) is L -composite. Then u − L = S x ∈ Σ ∗ ,x ≺ r u x − L .On the other hand, since (cid:52) r is a right L -preserving quasiorder, we have that (cid:52) r ⊆ (cid:52) rL , asshown de Luca and Varricchio [6]. Therefore u − L ⊇ S x ∈ Σ ∗ ,x ≺ r u x − L . There are now twopossibilities:For all x ∈ Σ ∗ such that x ≺ r u we have that x ≺ r u . In that case we have that u − L = S x ∈ Σ ∗ , x ≺ r u x − L , hence cl (cid:52) r ( u ) is L -composite. There exists x ∈ Σ ∗ such that x ≺ r u , hence x (cid:52) r u , but x r u . In that case, it followsthat cl (cid:52) r ( x ) = cl (cid:52) r ( u ). (cid:74) The following lemma allows us to conclude that
Can r ( L ) is invariant to our residualizationoperation Res r . (cid:73) Lemma 34.
Let L be a regular language and let (cid:52) r be a right quasiorder such that cl (cid:52) r ( L ) = L . Let H = H r ( (cid:52) r , L ) . If H is a strongly consistent RFA then (cid:52) r H = (cid:52) r . Proof.
Let N = ( Q, Σ , δ, I, F ) and H = ( e Q, Σ , e δ, e I, e F ). As shown by Lemma 4, H = H r ( (cid:52) r , L )is an RFA accepting L , hence each state of H is an L -prime principal cl (cid:52) r ( u ) whose rightlanguage is the quotient u − L for some u ∈ Σ ∗ .Observe that (cid:52) r H = (cid:52) r holds iff for every u, v ∈ Σ ∗ , post H u ( e I ) ⊆ post H v ( e I ) ⇔ u (cid:52) r v . Nextwe show that:post H u ( e I ) = { cl (cid:52) r ( x ) ∈ e Q | x (cid:52) r u } . (5)First, we prove that post H u ( e I ) ⊆ { cl (cid:52) r ( x ) ∈ e Q | x (cid:52) r u } . Let cl denote cl (cid:52) r .cl( x ) ∈ post H u ( e I ) ⇔ [By definition of post H u ( e I )] ∃ cl( x ) ∈ e I, u ∈ W H cl( x ) , cl( x ) ⇒ [By Definition 3] ∃ cl( x ) ∈ e Q, ε ∈ cl( x ) ∧ cl( x ) u ⊆ cl( x ) ⇔ [By definition of cl] ∃ cl( x ) ∈ e Q, x (cid:52) r ε ∧ x (cid:52) r x u ⇒ [Since x (cid:52) r ε ⇒ x u (cid:52) r u ] x (cid:52) r u . We now prove the reverse inclusion. Let cl( u ) , cl( x ) ∈ e Q be such that x (cid:52) r u . Then,cl( u ) ∈ e Q ⇒ [By Lemma 4] W H cl( u ) ,F = u − L ⇒ [Since H is strly. consistent] u ∈ W H I, cl( u ) ⇒ [By def. W H S,T with u = za ] ∃ cl( y ) ∈ e Q, cl( u ) ∈ e I, z ∈ W cl( u ) ,q ∧ a ∈ W cl( y ) , cl( u ) ⇒ [By Definition 3] ∃ cl( y ) ∈ e Q, cl( u ) ∈ e I, cl( u ) z ⊆ cl( y ) ∧ cl( y ) a ⊆ cl( u ) ⇒ [By definition of cl = cl (cid:52) r ] ∃ cl( y ) ∈ e Q, cl( u ) ∈ e I, cl( u ) z ⊆ cl( y ) ∧ u (cid:52) r ya ⇒ [Since x (cid:52) r u ] ∃ cl( y ) ∈ e Q, cl( u ) ∈ e I, cl( u ) z ⊆ cl( y ) ∧ x (cid:52) r ya ⇒ [By definition of cl = cl (cid:52) r ] ∃ cl( y ) ∈ e Q, cl( u ) ∈ e I, cl( u ) z ⊆ cl( y ) ∧ cl( y ) a ⊆ cl( x ) ⇒ [By definition of post H u ( e I )]cl( x ) ∈ post u ( I ) . It follows from Equation (5) that post H u ( I ) ⊆ post H v ( I ) ⇔ u (cid:52) r v , i.e., (cid:52) r H = (cid:52) r . (cid:74) The following lemma shows that, if we consider the right Nerode’s quasiorder (cid:52) rL thencomposite principals can be described as intersections of prime principals. (cid:73) Lemma 35.
Let N = ( Q, Σ , δ, I, F ) be an NFA with L ( N ) = L . Then, u − L = [ x ∈ Σ ∗ , x ≺ rL u x − L = ⇒ cl (cid:52) rL ( u ) = \ x ∈ Σ ∗ , x ≺ rL u cl (cid:52) rL ( x ) . (6) Proof.
Observe that the inclusion cl (cid:52) rL ( u ) ⊆ T x ∈ Σ ∗ ,x ≺ rL u cl (cid:52) rL ( x ) always holds since x ≺ rL u ⇒ cl (cid:52) rL ( u ) ⊆ cl (cid:52) rL ( x ). Next, we show the reverse inclusion. . Ganty and E. Gutiérrez and P. Valero 17 Algorithm NL (cid:52)
Quasiorder-based version of NL ∗ Data: A Teacher that answers membership queries in L Data: An Oracle that answers equivalence queries between the language accepted byan RFA and L Result:
The canonical RFA for the language L . P , S := { ε } ; while True do while (cid:52) rL S not closed or consistent: do if (cid:52) rL S is not closed then Find u ∈ P , a ∈ Σ with cl (cid:52) rL S ( u ) L S -prime for P and ∀ v ∈ P , cl (cid:52) rL S ( u ) = cl (cid:52) rL S ( v ); Let P := P ∪ { ua } ; if (cid:52) rL S is not consistent then Find u, v ∈ P , a ∈ Σ with u (cid:52) rL S v s.t. ua (cid:52) rL S va ; Find x ∈ (( ua ) − L ∩ S ) ∩ (( va ) − L ∩ S ) c ; Let S := S ∪ { ax } ; Build R ( (cid:52) rL S , P ); Ask the
Oracle whether L = L ( R ( (cid:52) rL S , P )); if the Oracle replies with a counterexample w then Let S := S ∪{ x ∈ Σ ∗ | w = w x with w ∈ S , w ∈ Σ ∗ } ; else return R ( (cid:52) rL S , P );Assume that the left hand side of Equation (6) holds and let w ∈ T x ∈ Σ ∗ ,x ≺ rL u cl (cid:52) rL ( x ).Then, by definition of intersection and cl (cid:52) rL , we have that x (cid:52) rL w for every x ∈ Σ ∗ suchthat x ≺ rL u , i.e., x − L ⊆ w − L for every word x ∈ Σ ∗ such that x − L (cid:40) u − L . Since,by hypothesis, u − L = S x ∈ Σ ∗ , x ≺ rL u x − L , it follows that u − L ⊆ w − L and, therefore, w ∈ cl (cid:52) r ( u ). We conclude that T x ∈ Σ ∗ ,x ≺ rL u cl (cid:52) rL ( x ) ⊆ cl (cid:52) rL ( u ). (cid:74) Finally, we show algorithm NL (cid:52) , the quasiorder-based version of the algorithm NL ∗ . C Deferred Proofs (cid:73)
Lemma 1.
The following properties hold: (cid:52) r is a right quasiorder iff cl (cid:52) r ( u ) v ⊆ cl (cid:52) r ( uv ) , for all u, v ∈ Σ ∗ . (cid:52) ‘ is a left quasiorder iff v cl (cid:52) ‘ ( u ) ⊆ cl (cid:52) ‘ ( vu ) , for all u, v ∈ Σ ∗ . Proof.1. (cid:52) r is a right quasiorder iff cl (cid:52) r ( v ) u ⊆ cl (cid:52) r ( vu ), for all u, v ∈ Σ ∗ .( ⇒ ). Let x ∈ cl (cid:52) r ( v ) u . Then, x = ˜ vu with v (cid:52) r ˜ v . Since (cid:52) r is a right quasiorder and v (cid:52) r ˜ v then vu (cid:52) r ˜ vu . Therefore x ∈ cl (cid:52) r ( vu ).( ⇐ ). Assume that for each u, v ∈ Σ ∗ and ˜ v ∈ cl (cid:52) r ( v ) we have that ˜ vu ∈ cl (cid:52) r ( vu ). Then, v (cid:52) r ˜ v ⇒ vu (cid:52) r ˜ vu . (cid:52) ‘ is a left quasiorder iff u cl (cid:52) ‘ ( v ) ⊆ cl (cid:52) ‘ ( uv ), for all u, v ∈ Σ ∗ .( ⇒ ). Let x ∈ u cl (cid:52) ‘ ( v ). Then, x = u ˜ v with v (cid:52) ‘ ˜ v . Since (cid:52) ‘ is a left quasiorder and v (cid:52) ‘ ˜ v then uv (cid:52) ‘ u ˜ v . Therefore x ∈ cl (cid:52) ‘ ( uv ). ( ⇐ ). Assume that for each u, v ∈ Σ ∗ and ˜ v ∈ cl (cid:52) ‘ ( v ) we have that u ˜ v ∈ cl (cid:52) ‘ ( uv ). Then v (cid:52) ‘ ˜ v ⇒ uv (cid:52) ‘ u ˜ v . (cid:74)(cid:73) Lemma 4.
Let L ⊆ Σ ∗ be a regular language and let (cid:52) r be a right L -preserving quasiorder.Then H r ( (cid:52) r , L ) is an RFA such that L ( H r ( (cid:52) r , L )) = L . Proof.
To simplify the notation, we denote cl (cid:52) r , the closure induced by the quasiorder (cid:52) r ,simply by cl. Let H = H r ( (cid:52) r , L ) = ( Q, Σ , δ, I, F ). We first show that H is an RFA. W H cl( u ) ,F = u − L, for each cl( u ) ∈ Q . (7)Let us prove that w ∈ u − L ⇒ w ∈ W H cl( u ) ,F . We proceed by induction on | w | . Base case:
Assume w = ε . Then, ε ∈ u − L ⇒ u ∈ L ⇒ cl( u ) ∈ F ⇒ ε ∈ W H cl( u ) ,F . Inductive step:
Assume that the hypothesis holds for each x ∈ Σ ∗ with | x | ≤ n ( n ≥ w ∈ Σ ∗ be such that | w | = n +1. Then w = ax with | x | = n and a ∈ Σ. ax ∈ u − L ⇒ [By definition of quotient] x ∈ ( ua ) − L ⇒ [By Defs. 2 and 3, cl( ua ) is L -prime (so z def = ua ) or ( ua ) − L = [ x i ≺ r ua x − i L (so z def = x i )] ∃ cl( z ) ∈ Q, x ∈ z − L ∧ cl( ua ) ⊆ cl( z ) ⇒ [By I.H., cl( u ) a ⊆ cl( ua ) and Def. 3] x ∈ W H cl( z ) ,F ∧ cl( z ) ∈ δ (cl( u ) , a ) ⇒ [By definition of W S,T ] ax ∈ W H cl( u ) ,F . We now prove the other side of the implication, i.e., w ∈ W H cl( u ) ,F ⇒ w ∈ u − L . Base case:
Let w = ε . By Definition 3, ε ∈ W H cl( u ) ,F ⇒ ∃ cl( x ) ∈ Q, x ∈ L ∧ cl( u ) ε ⊆ cl( x ).Since cl( L ) = L , we have that u ε ∈ L , hence ε ∈ u − L . Inductive step:
Assume the hypothesis holds for each x ∈ Σ ∗ with | x | ≤ n ( n ≥
1) andlet w ∈ Σ ∗ be such that | w | = n +1. Then w = ax with | x | = n and a ∈ Σ. ax ∈ W H cl( u ) ,F ⇒ [By Definition 3] x ∈ W H cl( y ) ,F ∧ cl( u ) a ⊆ cl( y ) ⇒ [By I.H. and since cl is induced by (cid:52) r ] x ∈ y − L ∧ y (cid:52) r ua ⇒ [Since u (cid:52) r v ⇒ u − L ⊆ v − L [6] ] x ∈ y − L ∧ y − L ⊆ ( ua ) − L ⇒ [Since x ∈ ( ua ) − L ⇒ ax ∈ u − L ] ax ∈ u − L .
We have shown that H is an RFA. Finally, we show that L ( H ) = L . First note that, L ( H ) = [ cl( u ) ∈ I W H cl( u ) ,F = [ cl( u ) ∈ I u − L , where the first equality holds by definition of L ( H ) and the second by Equation (7). Onone hand, we have that S cl( u ) ∈ I u − L ⊆ L since, by Definition 3, ε ∈ cl( u ), for eachcl( u ) ∈ I , and therefore u (cid:52) r ε which, as shown by de Luca and Varricchio [6], implies that u − L ⊆ ε − L = L . Let us show that L ⊆ S cl( u ) ∈ I u − L . First, let us assume that cl( ε ) ∈ I .Then, L = ε − L ⊆ [ cl( u ) ∈ I u − L . . Ganty and E. Gutiérrez and P. Valero 19
Now suppose that cl( ε ) / ∈ I , i.e., cl( ε ) is L -composite. Then L = ε − L = [ u ≺ r ε u − L = [ cl( u ) ∈ I u − L . where the last equality follows from cl( u ) ∈ I ⇔ ε ∈ cl( u ). (cid:74)(cid:73) Lemma 6.
Let L ⊆ Σ ∗ be a language and let (cid:52) ‘ be a left L -preserving quasiorder. Then H ‘ ( (cid:52) ‘ , L ) is a co-RFA such that L ( H ‘ ( (cid:52) ‘ , L )) = L . Proof.
To simplify the notation we denote cl (cid:52) ‘ , the closure induced by the quasiorder (cid:52) ‘ ,simply by cl. Let H = H ‘ ( (cid:52) ‘ , L ) = ( Q, Σ , δ, I, F ). We first show that H is a co-RFA. W H I, cl( u ) = Lu − , for each cl( u ) ∈ Q . (8)Let us prove that w ∈ Lu − ⇒ w ∈ W H I, cl( u ) . We proceed by induction. Base case:
Let w = ε . Then, ε ∈ Lu − ⇒ u ∈ L ⇒ cl( u ) ∈ I ⇒ ε ∈ W H I, cl( u ) . Inductive step:
Assume the hypothesis holds for all x ∈ Σ ∗ with | x | ≤ n ( n ≥
1) and let w ∈ Σ ∗ be such that | w | = n +1. Then w = xa with | x | = n and a ∈ Σ. xa ∈ Lu − ⇒ [By definition of quotient] x ∈ L ( au ) − ⇒ [By Defs. 2 and 5, cl( au ) is L -prime (so z def = au ) or L ( au ) − = [ x i ≺ ‘ au Lx − i (so z def = x i )] ∃ cl( z ) ∈ Q, x ∈ Lz − ∧ cl( au ) ⊆ cl( z ) ⇒ [By I.H., a cl( u ) ⊆ cl( au ) and Def. 5] x ∈ W H I, cl( z ) ∧ cl( u ) ∈ δ (cl( z ) , a ) ⇒ [By definition of W S,T ] xa ∈ W H I, cl( u ) . We now prove the other side of the implication, i.e., w ∈ W H I, cl( u ) ⇒ w ∈ Lu − . Base case:
Let w = ε . Then ε ∈ W H I, cl( u ) ⇒ ∃ cl( x ) ∈ Q, x ∈ L ∧ ε cl( u ) ⊆ cl( x ). Sincecl( L ) = L , we have that εu ∈ L , hence ε ∈ Lu − . Inductive step:
Assume the hypothesis holds for all x ∈ Σ ∗ with | x | ≤ n and let w ∈ Σ ∗ be such that | w | = n +1. Then w = xa with | x | = n and a ∈ Σ. xa ∈ W H I, cl( u ) ⇒ [By Definition 5] a cl( u ) ⊆ cl( y ) ∧ x ∈ W H I, cl( y ) ⇒ [By I.H. and since cl is induced by (cid:52) ‘ ] y (cid:52) ‘ au ∧ x ∈ Ly − ⇒ [Since u (cid:52) ‘ v ⇒ Lu − ⊆ Lv − [6] ] Ly − ⊆ L ( au ) − ∧ x ∈ Ly − ⇒ [Since x ∈ L ( au ) − ⇒ xa ∈ Lu − ] xa ∈ u − L .
We have shown that H is a co-RFA. Finally, we show that L ( H ) = L . First note that, L ( H ) = [ cl( u ) ∈ F W H I, cl( u ) = [ cl( u ) ∈ F Lu − , where the first equality holds by definition of L ( H ) and the second by Equation (8). Onone hand, we have that S cl( u ) ∈ F Lu − ⊆ L since, by Definition 5, ε ∈ cl( u ), for eachcl( u ) ∈ F , and therefore u (cid:52) ‘ ε which, as shown by de Luca and Varricchio [6], implies that Lu − ⊆ Lε − = L . Let us show that L ⊆ S cl( u ) ∈ F Lu − . First, suppose that cl( ε ) ∈ F .Then, L = Lε − ⊆ [ cl( u ) ∈ F Lu − . Now suppose that cl( ε ) / ∈ F , i.e., cl( ε ) is L -composite. Then L = Lε − = [ u ≺ ‘ ε Lu − = [ cl( u ) ∈ F u − L . where the last equality follows from cl( u ) ∈ F ⇔ ε ∈ cl( u ). (cid:74)(cid:73) Lemma 7.
Let (cid:52) r and (cid:52) ‘ be a right and a left quasiorder, respectively, and let L ⊆ Σ ∗ bea language. If u (cid:52) r v ⇔ u R (cid:52) ‘ v R then H r ( (cid:52) r , L ) is isomorphic to (cid:0) H ‘ ( (cid:52) ‘ , L R ) (cid:1) R . Proof.
Let H r ( (cid:52) r , L ) = ( Q, Σ , δ, I, F ) and ( H ‘ ( (cid:52) ‘ , L R )) R = ( e Q, Σ , e δ, e I, e F ). We will showthat H r ( (cid:52) r , L ) is isomorphic to ( H ‘ ( (cid:52) ‘ , L R )) R .Let ϕ : Q → e Q be a mapping assigning to each state cl (cid:52) r ( u ) ∈ Q with u ∈ Σ ∗ , the statecl (cid:52) ‘ ( u R ) ∈ e Q . We show that ϕ is an NFA isomorphism between H r ( (cid:52) r , L ) and ( H ‘ ( (cid:52) ‘ , L R )) R .Observe that: u − L = [ x ≺ r u x − L ⇔ [Since (cid:0) [ S i (cid:1) R = [ S Ri ]( u − L ) R = [ x ≺ r u ( x − L ) R ⇔ [Since ( u − L ) R = L R ( u R ) − ] L R ( u R ) − = [ x ≺ r u L R ( x R ) − ⇔ [By hypothesis, u ≺ r v ⇔ u R ≺ r v R ] L R ( u R ) − = [ x R ≺ ‘ u R L R ( x R ) − . It follows that cl (cid:52) r ( u ) is L -composite iff cl (cid:52) ‘ ( u R ) is L R -composite, hence ϕ ( Q ) = e Q .Since ε ∈ cl (cid:52) r ( u ) ⇔ u (cid:52) r ε ⇔ u r (cid:52) ‘ ε ⇔ ε ∈ cl (cid:52) ‘ ( u R ), we have that cl (cid:52) r ( u ) is aninitial state of H r ( (cid:52) r , L ) iff cl (cid:52) ‘ ( u R ) is a final state of H ‘ ( (cid:52) ‘ , L R ), i.e. an initial state of( H ‘ ( (cid:52) ‘ , L R )) R . Therefore, ϕ ( I ) = e I .Since cl (cid:52) r ( u ) ⊆ L ⇔ u ∈ L ⇔ u r ∈ L R , we have that cl (cid:52) r ( u ) is a final state of H r ( (cid:52) r , L )iff cl (cid:52) ‘ ( u R ) is an initial state of H ‘ ( (cid:52) ‘ , L R ), i.e. a final state of ( H ‘ ( (cid:52) ‘ , L R )) R . Therefore, ϕ ( F ) = e F .It remains to show that q ∈ δ ( q, a ) ⇔ ϕ ( q ) ∈ e δ ( ϕ ( q ) , a ), for all q, q ∈ Q and a ∈ Σ.Assume that q = cl (cid:52) r ( u ) for some u ∈ Σ ∗ , q = cl (cid:52) r ( v ) for some v ∈ Σ ∗ and q ∈ δ ( q, a ) with a ∈ Σ. Then,cl (cid:52) r ( v ) ∈ δ (cl (cid:52) r ( u ) , a ) ⇔ [By Definition 3]cl (cid:52) r ( u ) a ⊆ cl (cid:52) r ( v ) ⇔ [By definition of cl (cid:52) r and Lemma 1] v (cid:52) r ua ⇔ [Since u (cid:52) r v ⇔ u R (cid:52) ‘ v R and ( ua ) R = au R ] v r (cid:52) ‘ au R ⇔ [By definition of cl (cid:52) ‘ and Lemma 1] a cl (cid:52) ‘ ( u R ) ⊆ cl (cid:52) ‘ ( v R ) ⇔ [By Definition 5 and reverse automata]cl (cid:52) ‘ ( u R ) ∈ e δ (cl (cid:52) ‘ ( v R ) , a ) ⇔ [Definition of q, q and ϕ ] ϕ ( q ) ∈ e δ ( ϕ ( q ) , a ) . (cid:74) . Ganty and E. Gutiérrez and P. Valero 21 (cid:73) Theorem 8.
Let L ⊆ Σ ∗ be a language and let (cid:52) and (cid:52) be two left or two right L -preserving quasiorders. If (cid:52) ⊆ (cid:52) then: |{ cl (cid:52) ( u ) | u ∈ Σ ∗ ∧ cl (cid:52) ( u ) is L -prime }| ≥ |{ cl (cid:52) ( u ) | u ∈ Σ ∗ ∧ cl (cid:52) ( u ) is L -prime }| . Proof.
We proceed by showing that for every L -prime cl (cid:52) ( u ) there exists an L -prime cl (cid:52) ( x )such that cl (cid:52) ( x ) = cl (cid:52) ( u ). Clearly, this entails that there are, at least, as many L -primeprincipals for (cid:52) as there are for (cid:52) .Let cl (cid:52) ( u ) be L -prime.If cl (cid:52) ( u ) is L -prime, we are done. Otherwise, by Lemma 33, we have that there exists x ≺ u such that cl (cid:52) ( u ) = cl (cid:52) ( x ).We repeat the reasoning with x . If cl (cid:52) ( x ) is L -prime, we are done. Otherwise, thereexists x ≺ x such that cl (cid:52) ( u ) = cl (cid:52) ( x ) = cl (cid:52) ( x ).Since (cid:52) induces finitely many principals, there are no infinite strictly descending chainsand, therefore, there exists x n such that cl (cid:52) ( u ) = cl (cid:52) ( x ) = cl (cid:52) ( x ) = . . . = cl (cid:52) ( x n ) andcl (cid:52) ( x n ) is L -prime. (cid:74)(cid:73) Lemma 12.
Let N = ( Q, Σ , δ, I, F ) be an NFA with L ( N ) = L . Then, for every u ∈ Σ ∗ , cl (cid:52) r N ( u ) = \ q ∈ post N u ( I ) W N I,q cl (cid:52) rL ( u ) = \ w ∈ Σ ∗ , w ∈ u − L Lw − cl (cid:52) ‘ N ( u ) = \ q ∈ pre N u ( I ) W N q,F cl (cid:52) ‘L ( u ) = \ w ∈ Σ ∗ , w ∈ Lu − w − L .
Proof.
We prove the lemma for the principals induced by (cid:52) r N and (cid:52) rL . The proofs for theleft quasiorders are symmetric.For each u ∈ Σ ∗ we have that cl (cid:52) r N ( u ) = [By definition of cl (cid:52) r N ] { v ∈ Σ ∗ | post N u ( I ) ⊆ post N v ( I ) } = [By definition of set inclusion] { v ∈ Σ ∗ | ∀ q ∈ post N u ( I ) , q ∈ post N v ( I ) } = [Since q ∈ post N v ( I ) ⇔ v ∈ W N I,q ] { v ∈ Σ ∗ | ∀ q ∈ post N u ( I ) , v ∈ W N I,q } = [By definition of intersection] \ q ∈ post N u ( I ) W N I,q . On the other hand, v ∈ \ w ∈ Σ ∗ , w ∈ u − L Lw − ⇔ [By definition of intersection] ∀ w ∈ Σ ∗ , w ∈ u − L ⇒ v ∈ Lw − ⇔ [Since ∀ x, y ∈ Σ ∗ , x ∈ Ly − ⇔ y ∈ x − L ] ∀ w ∈ Σ ∗ , w ∈ u − L ⇒ w ∈ v − L ⇔ [By definition of set inclusion] u − L ⊆ v − L ⇔ [By definition of cl (cid:52) rL ( u )] v ∈ cl (cid:52) rL ( u ) (cid:74)(cid:73) Lemma 13.
Let N be a co-RFA with no empty states such that L = L ( N ) . Then (cid:52) rL = (cid:52) r N .Similarly, if N is an RFA with no unreachable states and L = L ( N ) then (cid:52) ‘L = (cid:52) ‘ N . Proof.
We have that post N u ( I ) ⊆ post N v ( I ) ⇒ W N post N u ( I ) ,F ⊆ W N post N v ( I ) ,F holds for everyNFA N and u, v ∈ Σ ∗ . Next we show that the reverse implication holds. Let u, v ∈ Σ ∗ besuch that W N post N u ( I ) ,F ⊆ W N post N v ( I ) ,F . Then, q ∈ post N u ( I ) ⇒ [Since N is co-RFA with no empty states] ∃ x ∈ Σ ∗ , u ∈ W I,q = Lx − ⇒ [Since u ∈ Lx − ⇒ x ∈ u − L ] x ∈ W post N u ( I ) ,F ⇒ [Since W N post N u ( I ) ,F ⊆ W N post N v ( I ) ,F ] x ∈ W post N v ( I ) ,F ⇒ [By definition of W N S,T ] ∃ q ∈ Q, x ∈ W q ,F ∧ v ∈ W I,q ⇒ [Since x ∈ W q ,F ⇒ W I,q ⊆ Lx − ] v ∈ Lx − ⇒ [Since Lx − = W I,q ] v ∈ W I,q ⇒ [By definition of post N v ( I )] q ∈ post N v ( I ) . Therefore, W N post N u ( I ) ,F ⊆ W N post N v ( I ) ,F ⇒ post N u ( I ) ⊆ post N v ( I ).The proof for RFAs with no unrechable states and left quasiorders is symmetric. (cid:74)(cid:73) Theorem 15.
Let N be an NFA with L = L ( N ) . Then the following properties hold: (a) L ( Can r ( L )) = L ( Can ‘ ( L )) = L = L ( Res r ( N )) = L ( Res ‘ ( N )) . (b) Can ‘ ( L ) is isomorphic to ( Can r ( L R )) R . (c) Res ‘ ( N ) is isomorphic to ( Res r ( N R )) R . (d) Can r ( L ) is isomorphic to the canonical RFA for L . (e) Res r ( N ) is isomorphic to a sub-automaton of N res and L ( Res r ( N )) = L ( N res ) = L . (f) Res r ( Res ‘ ( N )) is isomorphic to Can r ( L ) . Proof.(a) L ( Can r ( L )) = L ( Can ‘ ( L )) = L = L ( Res r ( N )) = L ( Res ‘ ( N )).By Definition 14, Can r ( L ) = H r ( (cid:52) rL , L ) and Res r ( N ) = H r ( (cid:52) r N , L ). By Lemma 4, L ( H r ( (cid:52) rL , L )) = L ( H r ( (cid:52) r N , L )) = L . Therefore, L ( Can r ( L )) = L ( Res r ( L )) = L . Simil-arly, it follows from Lemma 6 that L ( Can ‘ ( L )) = L ( Res ‘ ( L )) = L . (b) Can ‘ ( L ) is isomorphic to ( Can r ( L R )) R .For every u, v ∈ Σ ∗ : u (cid:52) ‘L v ⇔ [By Definition 2] u − L ⊆ v − L ⇔ [ A ⊆ B ⇔ A R ⊆ B R ]( u − L ) R ⊆ ( v − L ) R ⇔ [Since ( u − L ) R = L R ( u R ) − ] L R ( u R ) − ⊆ L R ( v R ) − ⇔ [By Definition 9] u R (cid:52) rL R v R . Finally, it follows from Lemma 7 that
Can ‘ ( L ) is isomorphic to ( Can r ( L R )) R . (c) Res ‘ ( N ) is isomorphic to ( Res r ( N R )) R .For every u, v ∈ Σ ∗ : u (cid:52) ‘ N v ⇔ [By Defintion 10]pre N R u ( F ) ⊆ pre N R v ( F ) ⇔ [Since q ∈ pre N R x ( F ) iff q ∈ post N x R ( I )]post N u R ( I ) ⊆ post N v R ( I ) ⇔ [By Definition 10] u R (cid:52) ‘ N v R . It follows from Lemma 7 that
Res ‘ ( N ) is isomorphic to Res r ( N R ) R . (d) Can r ( L ) is isomorphic to the canonical RFA for L .Let Can r ( L ) = ( Q, Σ , δ, I, F ) and let C = ( e Q, Σ , η, e I, e F ) be the canonical RFA for L . Let ϕ : e Q → Q be the mapping assigning to each state e q i ∈ e Q of the form u − L , the state . Ganty and E. Gutiérrez and P. Valero 23 cl (cid:52) rL ( u ) ∈ Q , with u ∈ Σ ∗ . We show that ϕ is an NFA isomorphism between C and Can r ( L ).Since u − L ⊆ L ⇔ u (cid:52) rL ε ⇔ ε ∈ cl (cid:52) rL ( u ), the initial states u − L ∈ e I are mapped toinitial states cl (cid:52) rL ( u ) of C . Therefore, ϕ ( e I ) = I .On the other hand, since ε ∈ u − L ⇔ u ∈ L , each final state u − L ∈ e F is mapped to afinal state cl (cid:52) rL ( u ) of C . Therefore, ϕ ( e F ) = F Since cl (cid:52) rL ( u ) a ⊆ cl (cid:52) rL ( v ) ⇔ v (cid:52) rL ua ⇔ v − L ⊆ ( ua ) − L , it is straightforward to checkthat v − L = η ( u − L, a ) if and only if cl (cid:52) rL ( v ) ∈ δ (cl (cid:52) rL ( u ) , a ), for all u − L, v − L ∈ e q and a ∈ Σ.Finally, we need to show that ∀ u ∈ Σ ∗ , cl (cid:52) rL ( u ) ∈ Q ⇔ ∃ q i ∈ e Q, q i = u − L . Observethat: u − L = [ x ≺ rL u u − L ⇔ [By Definition 9] u − L = [ x − L (cid:40) u − L x − L .
It follows that ∀ u ∈ Σ ∗ , cl (cid:52) rL ( u ) is L -prime ⇔ u − L is prime and, therefore, ϕ ( e Q ) = Q . (e) Res r ( N ) is isomorphic to a sub-automaton of N res and L ( Res r ( N )) = L ( N res ).Given N = ( Q, Σ , δ, I, F ), recall that N res = ( Q r , Σ , δ r , I r , F r ) is the RFA built by theresidualization operation defined by Denis et al. [9]. Let Res r ( N ) = ( e Q, Σ , e δ, e I, e F ).We will show that there is a surjective mapping ϕ that associates states and transitionsof Res r ( N ) with states and transitions of N res . Moreover, if q ∈ e Q is initial (resp. final)then ϕ ( q ) ∈ Q r is initial (resp. final) and q ∈ e δ ( q, a ) ⇔ ϕ ( q ) ∈ δ r ( ϕ ( q ) , a ). In thisway, we conclude that Res r ( N ) is isomorphic to a sub-automaton of N res . Finally, since L ( N res ) = L ( N ) then it follows from Lemma 4 that L ( N res ) = L ( N ) = L ( Res r ( N )).Let ϕ : e Q → Q r be the mapping assigning to each state cl (cid:52) r N ( u ) ∈ e Q with u ∈ Σ ∗ , theset post N u ( I ) ∈ Q r .It is straightforward to check that the initial states e I = { cl (cid:52) r N ( u ) ∈ e Q | ε ∈ cl (cid:52) r N ( u ) } of Res r ( N ) are mapped into the set { post N u ( I ) | post N u ( I ) ⊆ post N ε ( I ) } which are theinitial states of N res .Similarly, each final state of Res r ( N ), cl (cid:52) r N ( u ) with u ∈ L ( N ), is mapped to post N u ( I )such that post N u ( I ) ∩ F = ∅ , hence, post N u ( I ) is a final state of N res .Moreover, since cl (cid:52) r N ( u ) a ⊆ cl (cid:52) r N ( v ) ⇔ v (cid:52) r N ua ⇔ post N v ( I ) ⊆ post N ua ( I ), it follows that ∀ u, v ∈ Σ ∗ such that post N u ( I ) , post N v ( I ) ∈ Q r , we have post N v ( I ) ∈ δ r (post N u ( I ) , a ) ⇔ cl (cid:52) r N ( v ) ∈ e δ (cl (cid:52) r N ( u ) , a ).Finally, we show that ∀ u ∈ Σ ∗ , cl (cid:52) r N ( u ) ∈ e Q ⇒ post N u ( I ) ∈ Q r . By definition of e Q and Q r , this is equivalent to showing that for every word u ∈ Σ ∗ , if post N u ( I ) is coverablethen cl (cid:52) r N ( u ) is L -composite. Observe that:post N u ( I ) = [ post N x ( I ) (cid:40) post N u ( I ) post N x ( I ) ⇔ [ x ≺ r N u ⇔ post N x ( I ) (cid:40) post N u ( I )]post N u ( I ) = [ x ≺ r N u post N x ( I ) ⇒ [Since W N post N u ( I ) ,F = u − L ] u − L = [ x ≺ r N u x − L .
It follows that if post N u ( I ) is coverable then cl (cid:52) r N ( u ) is L -composite, hence ϕ ( e Q ) ⊆ Q r . (f) Res r ( Res ‘ ( N )) is isomorphic to Can r ( L ).By Lemma 6, Res ‘ ( N ) is a co-RFA accepting the language L with no empty states hence,by Lemma 13, Res r ( Res ‘ ( N )) is isomorphic to Can r ( L ( Res ‘ ( N ))) = Can r ( L ( N )). (cid:74)(cid:73) Lemma 16.
Let N be an NFA with L = L ( N ) . Then (cid:52) rL = (cid:52) r N iff Res r ( N ) is isomorphicto Can r ( L ( N )) . Proof.
As shown by Theorem 15 (d),
Can r ( L ) is the canonical RFA for L , hence it is stronglyconsistent and, by Lemma 34, we have that (cid:52) r Can r ( L ) = (cid:52) rL . On the other hand, if Res r ( N ) isisomorphic to Can r ( L ) we have that (cid:52) r Res r ( N ) = (cid:52) r Can r ( L ) , and by Lemma 34, (cid:52) r Res r ( N ) = (cid:52) r N .It follows that if Res r ( N ) is isomorphic to Can r ( L ) then (cid:52) rL = (cid:52) r N .Finally, if (cid:52) rL = (cid:52) r N then H r ( (cid:52) rL , L ) = H r ( (cid:52) r N , L ( N )), i.e., Can r ( L ) = Res r ( N ). (cid:74)(cid:73) Theorem 27. NL (cid:52) builds the same sets P and S , performs the same queries to the Oracle and the
Teacher and returns the same RFA as NL ∗ , provided that both algorithms resolvenondeterminism the same way. Proof.
Let P , S ⊆ Σ ∗ be a prefix-closed and a suffix-closed finite set, respectively, and let T = ( T, P , S ) be the table built by algorithm NL ∗ . Observe that for every u, v ∈ P : u (cid:52) rL S v ⇔ [By Definition 23] u − L ⊆ S v − L ⇔ [By definition of quotient w.r.t S ] ∀ x ∈ S, ux ∈ L ⇒ vx ∈ L ⇔ [By definition of T ] ∀ x ∈ S, (r( u )( x ) = +) ⇒ (r( v )( x ) = +) ⇔ [By Definition 29]r( u ) v r( v ) . (9)Moreover, for every u, v ∈ P we have that u − L = S v − L iff r( u ) = r( v ).Next, we show that the join operator applied to rows corresponds to the set union appliedto quotients w.r.t S . Let u, v ∈ P and let x ∈ S . Then,(r( u ) t r( v ))( x ) = + ⇔ [By Definition 28](r( u )( x ) = +) ∨ (r( v )( x ) = +) ⇔ [By definition of row]( ux ∈ L ) ∨ ( vx ∈ L ) ⇔ [By definition of quotient w.r.t S ]( x ∈ u − L ) ∨ ( x ∈ v − L ) ⇔ [By definition of ∪ ] x ∈ u − L ∪ v − L . (10)Therefore, we can prove that r( u ) is T - prime iff cl (cid:52) rL S ( u ) is L S -prime w.r.t. P .r( u ) = F v ∈P , r( v ) (cid:64) r( u ) r( v ) ⇔ [By Equation (9)]r( u ) = F v ∈P , v − L (cid:40) S u − L r( v ) ⇔ [By Equation (10)] u − L = S S v ∈P , v − L (cid:40) S u − L v − L ⇔ [ v − L (cid:40) S u − L ⇔ u ≺ rL S v ] u − L = S S v ∈P , u ≺ rL S v v − L .
It follows from Definitions 25 (a) and 31 (a) and Equation (10) that T is closed iff (cid:52) rL S is closed. Moreover, it follows from Definitions 25 (b) and 31 (b) that T is consistent iff (cid:52) rL S is consistent.On the other hand, for every u, v ∈ P , a ∈ Σ and x ∈ S we have that:(r( u ) ⊆ r( v )) ∧ (r( ua )( x ) = +) ∧ (r( va )( x ) = − ) ⇔ [By Equation (9)] . Ganty and E. Gutiérrez and P. Valero 25 ( u (cid:52) rL S v ) ∧ ( uax ∈ L ) ∧ ( vax / ∈ L )It follows that if T and (cid:52) rL S are not consistent then both NL ∗ and NL (cid:52) can find the sameword ax ∈ Σ S and add it to S . Similarly, it is straightforward to check that if r( ua ) with u ∈ P and a ∈ Σ break consistency, i.e. it is T -prime and it is not equal to any r( v ) with v ∈ P , then cl (cid:52) rL S ( ua ) is L S -prime for P and not equal to any cl (cid:52) rL S ( v ) with v ∈ P . Thus,if T and (cid:52) rL S are not closed then both NL ∗ and NL (cid:52) can find the same word ua and add itto P .It remains to show that both algorithms build the same automaton modulo isomorphism,i.e., R ( T ) = ( e Q, Σ , e ( δ ) , e I, e F ) is isomorphic to R ( (cid:52) rL S , P ) = ( Q, Σ , δ, I, F ). Define the mapping ϕ : Q → e Q as ϕ (cl (cid:52) rL S ( u )) = r( u ). Then: ϕ ( Q ) = { ϕ (cl (cid:52) rL S ( u )) | u ∈ P ∧ cl (cid:52) rL S ( u ) is L S -prime w.r.t. P} = { r( u ) | u ∈ P ∧ r( u ) is T -prime } = e Q .ϕ ( I ) = { ϕ (cl (cid:52) rL S ( u )) | ε ∈ cl (cid:52) rL S ( u ) } = { r( u ) | u (cid:52) rL S ε } = { r( u ) | r( u ) v r( ε ) } = e I .ϕ ( F ) = { ϕ (cl (cid:52) rL S ( u )) | u ∈ L ∩ P} = { r( u ) | u ∈ L ∩ P} = { r( u ) | r( u )( ε ) = + } = e F .ϕ ( δ (cl (cid:52) rL S ( u ) , a )) = ϕ (cl (cid:52) rL S ( ua )) = { r( v ) | cl (cid:52) rL S ( u ) ∈ Q ∧ cl (cid:52) rL S ( u ) a ⊆ cl (cid:52) rL S ( v ) } = { r( v ) | r( v ) ∈ e Q ∧ v (cid:52) rL S ua } = { r( v ) | r( v ) ∈ e Q ∧ r( v ) v r( ua ) } = e δ (r( u ) , a ) = e δ ( ϕ (cl (cid:52) rL S ( u )) , a ) . Finally, we show that ϕ is an isomorphism. Clearly, the function ϕ is surjective since,for every u ∈ P , we have that r( u ) = ϕ (cl (cid:52) rL S ( u )). Moreover ϕ is injective since for every u, v ∈ P , r( u ) = r( v ) ⇔ u − L = S v − L , hence r( u ) = r( v ) ⇔ cl (cid:52) rL S ( u ) = cl (cid:52) rL S ( v ).We conclude that ϕ is an NFA isomorphism between R ( (cid:52) rL S , P )) and R ( T ). Therefore NL ∗ and NL (cid:52) exhibit the same behavior, provided that both algorithms resolve nondeterminismin the same way, as they both maintain the same sets P and S and build the same automataat each step.and build the same automataat each step.