Abstract 1 Introduction 2 Preliminaries 3 OPNI: a passive learning algorithm for DROCA 4 OCA-L: OPNI-guided active learning procedure for OCA 5 Experimental evaluation 6 Conclusion References Appendix A Section 4. OCA-L: OPNI-guided active learning procedure for OCA Appendix B Section 5. Experimental evaluation

Scalable Learning of One-Counter Automata via State-Merging Algorithms

Shibashis Guha ORCID Tata Institute of Fundamental Research, Mumbai, India Anirban Majumdar ORCID Independent researcher, Kolkata, India Prince Mathew ORCID Indian Institute of Technology Goa, Ponda, India A.V. Sreejith Indian Institute of Technology Goa, Ponda, India
Abstract

We propose One-counter Positive Negative Inference (OPNI), a passive learning algorithm for deterministic real-time one-counter automata (droca). Inspired by the RPNI algorithm for regular languages, OPNI constructs a droca consistent with any given valid sample set.

We further present a semi-algorithm for active learning of droca using OPNI, and provide an implementation of the approach. Our experimental results demonstrate that this approach scales more effectively than existing state-of-the-art algorithms. We also evaluate the performance of the proposed approach for learning visibly one-counter automata.

Keywords and phrases:
active learning, passive learning, one-counter automata, RPNI
Copyright and License:
[Uncaptioned image] © Shibashis Guha, Anirban Majumdar, Prince Mathew, and A.V. Sreejith; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Formal languages and automata theory
Related Version:
Extended Version: https://arxiv.org/abs/2509.05762
Supplementary Material:
Software: https://doi.org/10.5281/zenodo.17310292 [9]
Funding:
Prince Mathew and A.V. Sreejith would like to thank CEFIPRA for the project IFC/ 6602-1/2022/77. A.V. Sreejith would also like to thank the DST Matrics grant for the project MTR/2022/000788.
Editors:
C. Aiswarya, Ruta Mehta, and Subhajit Roy

1 Introduction

Automata learning and verification.

Automata learning constitutes a correct-by-construction synthesis technique aimed at inferring formal models – such as finite-state machines or Mealy machines – from observed system behaviour. It ensures that the inferred model remains consistent with the observed data. Closely linked to formal verification, automata learning plays a key role in model inference, facilitating formal analysis and validation of system behaviour. It may also be viewed as an inductive synthesis framework tailored for the construction of finite-state programs.

Active and passive learning of automata.

The L algorithm [3] of Angluin is a foundational algorithm in active automata learning. It learns a minimal deterministic finite automaton (dfa) that accepts an unknown regular language, using a query-based learning model. The learner interacts with a teacher (oracle) through two types of queries, called membership queries and equivalence queries. The L algorithm guarantees the learning of the minimal dfa in a number of steps polynomial in the size of the minimal dfa and the length of the longest counterexample.

Passive learning of dfa, for example, Regular Positive and Negative Inference (RPNI) [13], on the other hand, involves inferring a dfa from a fixed, finite dataset consisting of positive and negative examples of strings. The output of the algorithm is a dfa that accepts all positive examples and rejects all negative ones. The constructed dfa may depend on the input positive and negative examples. For arbitrary inputs, the dfa that is consistent with the input data may not be minimal.

One-counter automata and visibly one-counter automata.

Deterministic one-counter automata [14] are a subclass of deterministic pushdown automata that operate with a single integer counter, which can be incremented, decremented, or tested for zero during transitions. They serve as a simple model for programs with minimal memory – more powerful than finite automata, but less expressive than general deterministic pushdown automata. Deterministic real-time one-counter automata (droca) [4] form a subclass of deterministic one-counter automata that do not have ε-transitions.

Visibly pushdown automata (vpa) [1, 2] are a restricted subclass of pushdown automata where the type of stack operation (push, pop, or no operation) is determined by the input symbol. This restriction allows vpa to retain much of the expressive power of pushdown automata while ensuring desirable closure properties and algorithmic properties similar to finite automata. Unlike pushdown automata, deterministic visibly pushdown automata are equally expressive as nondeterministic ones. Deterministic visibly one-counter automata (voca) are both droca and deterministic vpa.

Contributions.

We present two new methods for learning droca, addressing both passive and active learning settings:

  • Our first contribution (Section 3) is a passive learning algorithm, called OPNI. Given a labelled set 𝖲 of words – partitioned into accepting and rejecting examples – along with counter values for all prefixes, OPNI synthesises a droca that is consistent with both the counter information and the acceptance labels.

  • Our second contribution (Section 4) is an active learning procedure, OCA-L. In this setting, the learner interacts with a teacher who possesses a target droca. The learner may issue membership, equivalence, and counter-value queries to infer the target automaton. OCA-L adapts the MinOCA framework [11] by replacing its SAT-based subroutine with our passive learner OPNI, leading to a simpler and significantly more scalable method.

We implemented OCA-L in Python and evaluated it on randomly generated droca. Our experiments (Section 5) show that OCA-L outperforms the state-of-the-art MinOCA algorithm in terms of scalability: while MinOCA fails on most droca with more than 10 states, OCA-L successfully learns most droca having 18 or fewer states. Additionally, we evaluated OCA-L for the class of voca. In this case, OCA-L demonstrates remarkable scalability, learning most voca with up to 60 states and nearly half with 100 states. In contrast, MinOCA fails to learn most voca with more than 20 states.

However, unlike MinOCA, OCA-L need not necessarily learn the minimal droca.

Related works.

In the passive learning framework, the learner receives a set of labelled examples and synthesises a model consistent with them. The classical RPNI algorithm [13] learns a dfa in polynomial time from a set of accepting and rejecting words.

Active learning of finite automata via membership and equivalence queries was pioneered by Angluin’s L algorithm [3]. In the context of learning one-counter automata, Fahmy and Roos [7] established the decidability of learning droca. Later, Neider and Löding [12] proposed an algorithm for learning voca, employing an additional partial-equivalence query. Building on Neider and Löding’s techniques, Bruyére et al. [5] proposed learning droca by combining counter-value queries – which return the counter value after processing a word. Mathew et al. [11] proposed an alternate algorithm (MinOCA) to learn droca. It employs SAT solvers to compute a minimal separating dfa. These algorithms have worst-case exponential runtime. Recent work [10] shows that active learning of droca is possible in polynomial time. However, the degree of the polynomial is large, making it impractical.

Organisation.

The remainder of the paper is organised as follows. Section 2 presents the necessary preliminaries. In Section 3, we introduce our passive learning algorithm, OPNI. Section 4 describes the active learning procedure, OCA-L. Section 5 reports on our experimental evaluation of OCA-L and compares its performance with the state-of-the-art MinOCA algorithm. Finally, Section 6 concludes the paper.

2 Preliminaries

For a finite set S, we denote by |S| the cardinality of S. Non-negative integers are denoted by , and [i,j] denotes the interval {i,i+1,,j}. The sign of a non-negative integer d (denoted by sign(d)) is 0 if d=0 and 1 otherwise.

An alphabet denoted by Σ is a finite set of letters and Σ (resp., Σ+) represents the set of all words including (resp., excluding) the empty word ε over the alphabet Σ. For a word w=a0a1a2an and non-negative integers i<j, we use w[ij] for the factor aiai+1aj and w[i] for the letter ai. Given a set SΣ of words, we write 𝖯𝗋𝖾𝖿(S) to denote the set of prefixes of all words in S.

We now define the length-lexicographic order (denoted by <llex) on words. First, we fix an arbitrary total order <lex on the letters in Σ. The order of words is inductively defined as follows: u<llexvif either|u|<|v|,or|u|=|v| and there exists x,y,zΣ and σ1,σ2Σ such that u=xσ1y,v=xσ2z and σ1<lexσ2. Note that this ordering is total and well-founded. Note also that this order can naturally be extended to pairs of words as follows: (u1,v1)<llex(u2,v2) if either u1<llexu2, or u1=u2 and v1<llexv2.

2.1 One-Counter Automata

A deterministic finite automaton (dfa) is a tuple D=(Q,Σ,δ,q0,F), where Q is a finite set of states, Σ is a finite input alphabet, δ:Q×ΣQ is the transition function, q0Q is the initial state, and FQ is the set of accepting (final) states.

Given a dfa D, we sometimes write q𝑎q to denote δ(q,a)=q. The transition function δ extends naturally to words in Σ in the usual way: for w=a1a2anΣ, we define δ(q,w)=δ(δ(δ(q,a1),a2),,an). We will write D(w) to denote δ(q0,w). A word wΣ is accepted by D if D(w)F. The language recognised by D, denoted as (D), is the set of all accepted words. Two dfa D1 and D2 are equivalent if (D1)=(D2).

Definition 1 (droca).

A deterministic real-time one-counter automaton (droca) is a tuple 𝒜=(Q,Σ,q0,δ0,δ1,F), where Q is a finite nonempty set of states, Σ is the input alphabet, q0Q is the initial state, δ0:Q×ΣQ×{0,+1} and δ1:Q×ΣQ×{0,+1,1} are the transition functions, and FQ is the set of final states.

Consider a droca 𝒜. A configuration of 𝒜 is a pair (q,n)Q×, where q denotes the current state and n is the counter value. The configuration (q0,0) is called the initial configuration of 𝒜. For an e{1,0,+1} and letter a, the transition between the configurations (p,n) and (q,n+e) on the symbol a is defined if δsign(n)(p,a)=(q,e). We use (p,n)𝑎(q,n+e) to denote this. The run of a word w=a1an in I’m not not 𝒜, if it exists, is the sequence of configurations (q0,m0)a1(q1,m1)an1(qn,mn) where m0=0. We will write (q0,m0)𝑤(qn,mn) to denote such a sequence. Further, we say mn is the counter-effect of w (denoted by 𝖼𝖾𝒜(w)). Note that the counter values always stay non-negative, implying a decrement is not permitted from a configuration with a zero counter value. We will say that w is accepted by 𝒜 if and only if qnF.

The language of 𝒜, denoted by (𝒜), is the set of all words accepted by 𝒜. Similar to the case of dfa, we will write 𝒜(w) to denote the state in 𝒜 that is reached after reading w. The definition of language equivalence is also similar to that above. Note that there are no ϵ-transitions in a droca. We say two droca 𝒜 and are counter-synchronous if 𝖼𝖾𝒜(w)=𝖼𝖾(w) for all words w.

A voca is a droca 111Syntactically, in a voca, the δ0 transition function includes -1. However, this is not semantically allowed since the counter value can never go below zero. where the input alphabet Σ is a union of three disjoint sets Σcall,Σret, and Σint. The voca increments (resp. decrements) its counter on reading a symbol from Σcall (resp. Σret). The counter value is unchanged on reading a symbol from Σint.

Definition 2 (voca).

A visibly one-counter automaton (voca) is a tuple 𝒜=(Q,ΣcallΣretΣint,q0,δ0,δ1,F), where Q is a finite nonempty set of states, Σ=ΣcallΣretΣint is the input alphabet, q0Q is the initial state, δ0:Q×ΣQ×{0,+1,1}, δ1:Q×ΣQ×{0,+1,1} are the transition functions, and FQ is the set of final states.

The notions of counter-effect, runs and transitions for voca remain the same as those of droca. From the definition, voca are deterministic. The counter-effect of a transition is solely based on Σ, making the starting state and counter value irrelevant. For σΣ:

𝖼𝖾𝒜(σ)={1, if σΣcall1, if σΣret, and0, if σΣinit

If w=σ1σ2σn for some n and σ1,,σnΣ, then 𝖼𝖾𝒜(w)=𝖼𝖾𝒜(σ1)+𝖼𝖾𝒜(σ2)++𝖼𝖾𝒜(σn). Since the counter value can never go below zero, there will be words that do not have a valid run in a voca. These words will be considered as rejected.

2.2 RPNI: a passive learning algorithm for DFA

Learning framework.

A pair of sets of words 𝖲=𝖲+𝖲 over an alphabet Σ is called a sample set, and words in 𝖲+ (resp., 𝖲) are called positive (resp., negative) samples. A sample set 𝖲 is called consistent if it satisfies the condition: 𝖲+𝖲=. Typically, in a passive learning framework for dfa, a learner is given an alphabet Σ, and a sample set 𝖲 over Σ, that is consistent, and the objective is to construct an automaton D such that D accepts all the words in 𝖲+ and rejects all the words in 𝖲. In that case, overloading the notation, we will say that D is consistent with the sample set 𝖲.

RPNI algorithm.

Here we recall RPNI, a state-of-the-art passive learning algorithm for dfa, originally proposed in [13]. Intuitively, the algorithm starts with a prefix tree acceptor (PTA) constructed from the positive samples 𝖲+, and then iteratively merges states of the PTA in a specific order (precisely, the length-lexicographic order), keeping the resulting dfa consistent with the samples set 𝖲. A pseudo-code of our version of RPNI is given in Algorithm 1. Below, we explain different steps of the algorithm.

Algorithm 1 RPNI: a passive learning algorithm for dfa.

We first construct a PTA (line 1) from the positive samples 𝖲+, which can formally be defined as a dfa PT=(Q,Σ,δ,qε,F), where Q={quu𝖯𝗋𝖾𝖿(𝖲+)} represents the set of states corresponding to all prefixes of words in 𝖲+, δ is defined as follows: for all u,uσ𝖯𝗋𝖾𝖿(𝖲+) with σΣ, we have δ(qu,σ)=quσ, the initial state qε is the state corresponding to the empty word ε, and F={quu𝖲+} is the set of all states that correspond to words in 𝖲+. We call a prefix u the representative of the state qu. Note that PT accepts exactly the words in 𝖲+.

We then aim to merge states of the PTA in the <llex ordering of their representatives, while preserving the consistency of the resulting dfa with the negative samples. To this end, we consider all pairs of prefixes (u,v) in 𝖯𝗋𝖾𝖿(𝖲+) such that u is greater than v with respect to the <llex ordering (line 2), and sort this set in the increasing <llex order (line 3). We then initialise the main loop of RPNI with PT (line 4), and continue until P becomes empty (line 5). Let D be the dfa at the beginning of an iteration. First, pop (u,v) which is the minimal element from P (line 6). Then perform a merge of the states D(u) and D(v) of D, i.e., check whether the merged dfa is consistent with respect to the sample set. If that is indeed (resp., not) the case, we accept (resp., discard) the merge, and update D accordingly (lines 7-8). Finally, we terminate when P becomes empty, and return the corresponding dfa.

The procedure Merge (line 8) takes as input a dfa D and two states D(u) and D(v), and returns a new dfa D that is obtained from D by merging those two states. We give a high-level idea of the procedure. First, if D(u)=D(v), then D=D. Otherwise, let us denote D(u) and D(v) by qu and qv, respectively. Also, recall that since (u,v) is in the ordered set, v<llexu. Let q be such that there exists a transition q𝑎qu in D for some aΣ. Then construct D as follows: delete the state qu from D, redirect all incoming transitions of qu to qv, and all outgoing transitions from qu will now be outgoing transitions of qv. To make D deterministic, we may need to recursively fold the subtree of qu into qv: if qu and qv have successors qu and qv on the same letter a, respectively, then merge qu and qv as well, and repeat this process until there is no common successor remaining.

The termination and correctness of Algorithm 1 were established in [13]. In Section 3, we will use RPNI as a black-box in our passive learning algorithm for droca.

3 OPNI: a passive learning algorithm for DROCA

In this section, we introduce OPNI, a passive learning algorithm for droca.

Learning framework.

For passive learning of droca, we enhance the input of the learning algorithm with the counter values of prefixes of all words in the sample set. More formally, we assume that along with a consistent sample set 𝖲=𝖲+𝖲 over an alphabet Σ, the learning algorithm is also provided with the counter-effects for all words in 𝖯𝗋𝖾𝖿(𝖲) defined by the function 𝖼𝖾:𝖯𝗋𝖾𝖿(𝖲). The learner aims to construct a droca 𝒜 that satisfies the following two properties: (1) it accepts all words in 𝖲+ and rejects all words in 𝖲, and (2) for all w𝖯𝗋𝖾𝖿(𝖲), 𝖼𝖾(w)=𝖼𝖾𝒜(w). In this case, we will say that 𝒜 is consistent with the sample set 𝖲.

As in [11], we define the following two functions.

  1. 1.

    Let Σ={σ1,,σk}. Define 𝖠𝖼𝗍:Σ{0,1}×{0,1,1,x}k which, given a word w, returns a tuple consisting of the sign of the counter value reached after reading w along with the effect on the counter on reading each letter from Σ after w. Formally, for any word w, and i[0,k],

    𝖠𝖼𝗍(w)[i]={sign(𝖼𝖾(w))if i=0𝖼𝖾(wσi)𝖼𝖾(w)if i>0 and 𝖼𝖾(wσi) is knownxif i>0 and 𝖼𝖾(wσi) is not known

    Given words w1,w2, we say that 𝖠𝖼𝗍(w1) is similar to 𝖠𝖼𝗍(w2) (denoted 𝖠𝖼𝗍(w1)𝖠𝖼𝗍(w2)) if one of the following happens: (a) for all i[1,k], we have 𝖠𝖼𝗍(w1)[i]=xor𝖠𝖼𝗍(w2)[i]=x or 𝖠𝖼𝗍(w1)[i]=𝖠𝖼𝗍(w2)[i], or (b) the sign of the counter values for words w1 and w2 are different, that is, 𝖠𝖼𝗍(w1)[0]𝖠𝖼𝗍(w2)[0]. (As it will be clear later, when 𝖠𝖼𝗍(w1)𝖠𝖼𝗍(w2), we might be able to merge the states reached after reading w1 and w2 respectively. The merging may be possible if the signs of the counter values are different, regardless of the other components in 𝖠𝖼𝗍.) Otherwise, 𝖠𝖼𝗍(w1) and 𝖠𝖼𝗍(w2) are not similar, and we write 𝖠𝖼𝗍(w1)≁𝖠𝖼𝗍(w2). For σΣ, we write 𝖠𝖼𝗍(w)|σ to denote the entry in 𝖠𝖼𝗍(w) that corresponds to the letter σ.

  2. 2.

    Define a function that, intuitively, given a word w, annotates each letter w[i] of w with the sign of the counter-value reached, upon reading the prefix w[0i1]. To that end, for an alphabet Σ, we define the modified alphabet Σ~=σΣ{σ0,σ1}. Then, given a word wΣ+ and the counter-values 𝖼𝖾 of all its prefixes, we define the encryption function as follows: for i[0,|w|1],

    𝖤𝗇𝖼(w)[i]={w[i]0if i=0w[i]sign(𝖼𝖾(w[0i1]))if i>0

    Additionally, 𝖤𝗇𝖼(ϵ)=ϵ.

Example 3.

Let Σ={a,b} and suppose the following counter-value information are given: 𝖼𝖾={ε0,a1,b0,ab0,bb1}. Then 𝖠𝖼𝗍(a)=(sign(𝖼𝖾(a)),𝖼𝖾(aa)𝖼𝖾(a),𝖼𝖾(ab)𝖼𝖾(a))=(1,x,1). On the other hand, the effect of the 𝖤𝗇𝖼 function on the word ab, for example, will be a0b1.

OPNI algorithm.

We now introduce OPNI, a passive learning algorithm for droca, that uses RPNI as a subroutine. A pseudo-code of the algorithm is given in Algorithm 2. The algorithm can be broadly divided into two major steps: (1) a preprocessing step that creates an enriched sample set (lines 1-3, Algorithm 2), and (2) the inference step that constructs a droca consistent with the sample set with the help of RPNI.

Algorithm 2 OPNI: a passive learning algorithm for droca.

In the preprocessing step, we incorporate the counter information about prefixes of 𝖲 to construct an input 𝖲^ for RPNI. To that end, we first replace every word u in 𝖲 with its encoding 𝖤𝗇𝖼(u) (line 1). Let us denote by 𝖤𝗇𝖼(𝖲) the set {𝖤𝗇𝖼(u)u𝖲}. We then consider the set Σ𝖠𝖼𝗍={𝖠𝖼𝗍(w)w𝖯𝗋𝖾𝖿(𝖲)}, and the modified alphabet Σ^=Σ~Σ𝖠𝖼𝗍 (line 2). Recall that, for an alphabet Σ, the alphabet Σ~ is defined as the set σΣ{σ0,σ1}. Finally, for every prefix w𝖯𝗋𝖾𝖿(𝖲), we add the word 𝖤𝗇𝖼(w)𝖠𝖼𝗍(w) to 𝖲^+, and for every other 𝗈𝗉Σ𝖠𝖼𝗍 such that 𝗈𝗉≁𝖠𝖼𝗍(w), we add the word 𝖤𝗇𝖼(w)𝗈𝗉 to 𝖲^ (line 3).

In the inference step, we run RPNI on the sample set 𝖲^ over the alphabet Σ^ (line 4). Let D^ denote the output dfa of RPNI, then we construct a droca 𝒜 from D^ using the construction given in the Procedure ConstructOCA (line 5).

Henceforth, we fix a Σ,𝖲,𝖼𝖾 and D^. In the remainder of this section, we present the Procedure ConstructOCA and prove the correctness of the OPNI algorithm. We start with the following lemmas (Lemmas 4 and 5) about the dfa D^.

Lemma 4.

The dfa D^ satisfies the following two properties:

  1. 1.

    for all words w𝖲+ (resp. w𝖲), we have 𝖤𝗇𝖼(w)(D^) (resp. 𝖤𝗇𝖼(w)(D^)),

  2. 2.

    for any two words w1,w2𝖯𝗋𝖾𝖿(S), if the runs on 𝖤𝗇𝖼(w1) and 𝖤𝗇𝖼(w2) reach the same state in D^, then 𝖠𝖼𝗍(w1)𝖠𝖼𝗍(w2).

Proof.
  1. 1.

    From line 1 of Algorithm 2, we have that, for all w𝖲+ (resp. w𝖲), 𝖤𝗇𝖼(w)𝖲^+ (resp. 𝖤𝗇𝖼(w)𝖲^). Then the property holds from the correctness of RPNI.

  2. 2.

    Assume, towards a contradiction, that there exist words w1,w2𝖲, such that the runs on 𝖤𝗇𝖼(w1) and 𝖤𝗇𝖼(w2) reach the same state in D^, but 𝖠𝖼𝗍(w1)≁𝖠𝖼𝗍(w2). From line 3 of Algorithm 2, we have that, 𝖤𝗇𝖼(w1)𝖠𝖼𝗍(w1)𝖲^+, and 𝖤𝗇𝖼(w2)𝖠𝖼𝗍(w1)𝖲^. Then due to the correctness of RPNI, it follows that 𝖤𝗇𝖼(w1)𝖠𝖼𝗍(w1)(D^), and 𝖤𝗇𝖼(w2)𝖠𝖼𝗍(w1)(D^). Now since 𝖤𝗇𝖼(w1) and 𝖤𝗇𝖼(w2) reaches the same state in D^, it must also be the case that, 𝖤𝗇𝖼(w2)𝖠𝖼𝗍(w1)(D^), which is a contradiction.

Lemma 5.

For all q,qQ and σΣ such that qσ0q (resp., qσ1q) is a transition in D^, there must exist 𝖺𝖼𝗍Σ𝖠𝖼𝗍 and qfQ such that 𝖺𝖼𝗍[0]=0 (resp., 𝖺𝖼𝗍[0]=1) and q𝖺𝖼𝗍qf. Furthermore, 𝖺𝖼𝗍|σ{0,+1} (resp., 𝖺𝖼𝗍|σ{1,0,+1}).

Proof.

Let q,qQ and σΣ be such that qσ0q. Then, there exists wσ𝖯𝗋𝖾𝖿(𝖲) such that q0𝖤𝗇𝖼(w)q in D^ with 𝖼𝖾(w)=0 and 𝖠𝖼𝗍(w)[0]=0Σ𝖠𝖼𝗍. The latter condition implies that 𝖤𝗇𝖼(w)𝖠𝖼𝗍(w)𝖲^+. Let 𝖺𝖼𝗍=𝖠𝖼𝗍(w). Therefore, from the correctness of RPNI, we have that 𝖤𝗇𝖼(w)𝖺𝖼𝗍(D^), which implies that there exists qfQ such that q𝖺𝖼𝗍qf in D^. Since wσ is in 𝖯𝗋𝖾𝖿(𝖲), and 𝖼𝖾(wσ) is given in the input, we have that 𝖺𝖼𝗍|σ{0,+1}. The proof for the other case, when the counter-effect of w is positive, is similar.

Procedure ConstructOCA.

Let D^=(Q,Σ^,q0,δ,F). We then define the droca 𝒜=(Q,Σ,q0,δ0,δ1,F) where δ0 and δ1 are specified as follows. For every qQ, σΣ, if there is a transition qσ0q for some q in D^, then, from Lemma 5, there exist 𝖺𝖼𝗍Σ𝖠𝖼𝗍 and qfQ such that 𝖺𝖼𝗍[0]=0 and q𝖺𝖼𝗍qf with 𝖺𝖼𝗍|σ{0,+1}. Let c=𝖺𝖼𝗍|σ. Then define δ0(q,σ)=(q,c). The definition of δ1 is analogous.

Lemma 6.

Let 𝒜=ConstructOCA(D^). Then, 𝒜 is consistent with the sample set 𝖲.

Proof.

We know, from Lemma 4, that for any word w1,w2Σ, if D^ on reading 𝖤𝗇𝖼(w1) and 𝖤𝗇𝖼(w2) reaches the same state, then 𝖠𝖼𝗍(w1) is similar to 𝖠𝖼𝗍(w2). This implies that the transition functions of 𝒜 are well-defined. We will now show that 𝒜 is consistent with the sample 𝖲.

Claim 7.

For all w𝖯𝗋𝖾𝖿(𝖲), 𝖼𝖾(w)=𝖼𝖾𝒜(w).

Proof.

We will prove this claim by induction on the length of w. This is trivial for w=ε (base case), since by definition, 𝖼𝖾(ε)=𝖼𝖾𝒜(ε)=0. Now, assume that the claim is true for all words u of length less than or equal to l, for some l0. Let uσ be a prefix in 𝖯𝗋𝖾𝖿(𝖲). We will show: 𝖼𝖾(uσ)=𝖼𝖾𝒜(uσ). Let q,qQ be such that D^(𝖤𝗇𝖼(u))=q, and qσcq is a transition in D^, where c=sign(𝖼𝖾(u)). Then, by the construction of 𝒜, we have that δc(q,σ)=(q,t) where t=𝖼𝖾(uσ)𝖼𝖾(u). Therefore, 𝖼𝖾𝒜(uσ)=𝖼𝖾𝒜(u)+t. Using the induction hypothesis, we can rewrite the above equation as 𝖼𝖾𝒜(uσ)=𝖼𝖾(u)+t=𝖼𝖾(uσ). This concludes the proof of the claim. Claim 7 also ensures that 𝖤𝗇𝖼(w)=𝖤𝗇𝖼𝒜(w). By construction of 𝒜, for all w𝖯𝗋𝖾𝖿(𝖲), D^(𝖤𝗇𝖼(w))=𝒜(w). Since, from Lemma 4, for all w𝖲+, we have 𝖤𝗇𝖼(w)(D^), thus we conclude that w(𝒜). Similarly for w𝖲, we have w(𝒜). Together with Claim 7, this concludes the proof of the lemma.

(a) Prefix Tree.
(b) Merge(PT;qε,qa0).
(c) Output of RPNI.
(d) Output droca.
Figure 1: Different steps of the OPNI algorithm on Example 8. Figure 1(a) represents the prefix tree PT; Figure 1(b) represents the dfa after merging qε and qa0; Figure 1(c) is the dfa that is the output of RPNI; Figure 1(d) is the droca output by the OPNI algorithm.

Let us now illustrate the OPNI algorithm with an example.

Example 8.

Let 𝖲=𝖲+𝖲 be a sample set over an alphabet Σ={a,b} with 𝖲+={ab,bb} and 𝖲={a,b}. Suppose the counter-values for words in 𝖯𝗋𝖾𝖿(𝖲) are: 𝖼𝖾={ε0,a1,b0,ab0,bb1}. Below, we illustrate different steps of OPNI on this example.

  • Using the 𝖤𝗇𝖼 function, construct (line 1) the modified sample set 𝖲^=𝖲^+𝖲^ where 𝖲^+={a0b1,b0b0} and 𝖲^={a0,b0} over the alphabet Σ^={a0,a1,b0,b1}.

  • Then, we construct (line 2) the set Σ𝖠𝖼𝗍 as follows. We evaluate the 𝖠𝖼𝗍 function for words in 𝖯𝗋𝖾𝖿(S). For example, 𝖠𝖼𝗍(ε)=(sign(𝖼𝖾(ε)),𝖼𝖾(a)𝖼𝖾(ε),𝖼𝖾(b)𝖼𝖾(ε))=(0,+1,0). Similarly, we compute 𝖠𝖼𝗍(w) for words in 𝖯𝗋𝖾𝖿(𝖲), and get 𝖠𝖼𝗍={ε(0,+1,0),a(1,x,1),ab(0,x,x),b(0,x,+1),bb(1,x,x)}. For simplicity and better readability, we assign symbols from the English alphabet to these action tuples, and write: (0,+1,0)=r,(1,x,1)=s,(0,x,x)=t,(0,x,+1)=u, and (1,x,x)=v and therefore, Σ𝖠𝖼𝗍={r,s,t,u,v}. Consequently, Σ^={a0,a1,b0,b1,r,s,t,u,v}.

  • We then enrich the sample set 𝖲^=𝖲^+𝖲^ as in line 3 of the algorithm. For example, since ε is a prefix of 𝖲, we will include 𝖤𝗇𝖼(ε)𝖠𝖼𝗍(ε)=r in 𝖲^+, and since u is not similar to r, we include u into 𝖲^. Doing this for other elements in 𝖲^, we get the following sets: 𝖲^+={a0b1,b0b0}{r,a0s,a0b1t,b0u,b0b0v}, and 𝖲^={a0,b0}{u,b0r}.

  • Next, we apply RPNI (line 4) to this newly constructed sample set 𝖲^ over the alphabet Σ^. Different steps of the RPNI algorithm on 𝖲^ are shown in Figure 1. The first two steps are depicted in Figure 1(a) and Figure 1(b), and Figure 1(c) represents the output of RPNI on 𝖲^. The intermediate steps of RPNI are shown in Figure 2.

  • Finally, we construct a droca 𝒜 from D^ using the Procedure ConstructOCA. For example, consider the transition q0b1q2 in D^. Due to Lemma 5, there must exist a transition from its source state q0 on an action 𝖺𝖼𝗍 with 𝖺𝖼𝗍[0]=1. We deduce that 𝖺𝖼𝗍=r=(1,x,1), and the transition is q0𝑟q2. Therefore, according to ConstructOCA procedure, we assign δ1(q0,b)=(q2,1). Figure 1(d) represents the output droca of ConstructOCA on D^.

(a) Merge of a0b1,r.
(b) Merge of a0s,r.
(c) Merge of b0b0,r.
(d) Merge of b0u,r.
Figure 2: Intermediate steps of the OPNI algorithm on Example 8.
Justification of counter values in the input.

We make use of the counter information in the preprocessing step to construct two sets: 𝖤𝗇𝖼(𝖲) and Σ𝖠𝖼𝗍. The counter-actions and signs of counter values in the input are required to prevent RPNI on the sample set 𝖲^ (line 4) from doing some of the merges. Let us illustrate this with an example. Suppose in a certain iteration of RPNI, we are trying to merge two states D(u) and D(v), for some prefixes u and v of 𝖲+, and let both states have outgoing transitions on a letter a. As such, if there is no information on the counter-actions, RPNI will merge these two states, provided that the merged automaton is consistent with 𝖲. However, suppose that sign(𝖼𝖾(u))=sign(𝖼𝖾(v)), but 𝖠𝖼𝗍(u)≁𝖠𝖼𝗍(v). In that case, these two states should not be merged, since in any droca that is consistent with the sample, u and v must lead to two different states. This justifies the construction of Σ𝖠𝖼𝗍. Now suppose that sign(𝖼𝖾(u))sign(𝖼𝖾(v)). In that case, those two states could very well be merged. This justifies the preprocessing steps in OPNI.

Since RPNI is guaranteed to terminate, together with Lemma 6, we conclude the following.

Theorem 9.

Algorithm 2 terminates and returns a droca consistent with the input.

4 OCA-L: OPNI-guided active learning procedure for OCA

In this section, we provide a procedure for active learning of droca using OPNI.

Learning framework.

Following [11, 5], in an active learning framework for droca, the learner’s aim is to construct a droca by interacting with a teacher that has a droca 𝒜 in mind, such that 𝒜 and are equivalent. In the process, the learner can ask the teacher three types of queries:

  • Membership queries MQA: the learner provides a word wΣ. The teacher returns 1 if w(𝒜), and 0 if w(𝒜).

  • Counter value queries CVA: the learner asks the counter value reached on reading a word w. The teacher returns the counter value, i.e., 𝖼𝖾𝒜(w).

  • Minimal synchronous-equivalence queries MSQA: the learner asks whether a droca 𝒞 is equivalent and counter-synchronous to 𝒜. The teacher returns yes only if 𝒞 and 𝒜 are counter-synchronous and equivalent. Otherwise, the teacher provides a counter-example zΣ with the smallest length such that either 𝒞(z)𝒜(z) or 𝖼𝖾𝒜(z)𝖼𝖾𝒞(z).

Note that the minimal synchronous-equivalence queries (introduced in [11]) may return a word for which the two machines reach different counter values. This query enables the active learning method to construct a droca that is counter-synchronous and equivalent to the teacher’s droca. As noted in [11], synchronous equivalence is significantly faster than the impractical general equivalence check. Hence, relaxing this condition and having minimal equivalence queries will require the teacher to use a general equivalence check. Thus, in our implementation (described in Section 5), we opt for equivalence queries on minimal counter-synchronous droca, as they are faster.

Learning of DROCA

We introduce an active learning procedure for droca, called OCA-L. The pseudocode is presented in Procedure 3, and its key components are detailed below. OCA-L builds on Angluin’s L algorithm with modifications inspired by the MinOCA framework from [11].

Observation table.

Consider an input alphabet Σ={σ1,,σk} for some k. The learner maintains an observation table T=(𝖱,𝖢,Memb,𝖼𝖾𝖱𝖱Σ,𝖠𝖼𝗍) over Σ. Here 𝖱 is a nonempty prefix-closed set of strings, 𝖢 is a nonempty suffix-closed set of strings, Memb:(𝖱𝖱Σ)𝖢{0,1} is a function that indicates whether a word belongs to the language, 𝖼𝖾𝖱𝖱Σ:𝖱𝖱Σ is the function 𝖼𝖾 with domain restricted to the set 𝖱𝖱Σ, and 𝖠𝖼𝗍:(𝖱𝖱Σ)𝖢{0,1}×{0,1,1}k is a function representing the sign of the counter value reached and the counter-actions on every letter after reading a word. The function 𝖠𝖼𝗍 is the same as the one defined in Section 3. Given w(𝖱𝖱Σ)𝖢, the function Memb(w) returns 0 (resp., 1) if 𝒜(w) is equal to 0 (resp., 1). The observation table initially has 𝖱=𝖢={ϵ} and is updated as the procedure runs. Let 𝖢={c1,,c} for some . For any r𝖱𝖱Σ, we use row(r) to denote the tuple (𝖼𝖾(r),(Memb(rc1),𝖠𝖼𝗍(rc1)),,(Memb(rc),𝖠𝖼𝗍(rc))).

Definition 10 (Definition 5 in [11]).

Let d and T=(𝖱,𝖢,Memb,𝖼𝖾𝖱𝖱Σ,𝖠𝖼𝗍) be an observation table.

  1. 1.

    T is said to be d-closed if for all r𝖱Σ with 𝖼𝖾(r)d there exists r𝖱 such that row(r)=row(r).

  2. 2.

    T is said to be d-consistent if for all r,s𝖱, such that 𝖼𝖾(r)=𝖼𝖾(s)d and row(r)=row(s) implies that for all σΣ, row(rσ)=row(sσ).

As described in Procedure 3 (see also [11]), the observation table is iteratively expanded until it satisfies the conditions of d-closure and d-consistency. The set of words w(𝖱𝖱Σ)𝖢 is partitioned into 𝖲+ and 𝖲, based on whether each word is accepted or rejected by the teacher. The goal is to construct a droca that solves the corresponding passive learning task: separating 𝖲+ from 𝖲 while being counter-synchronous with the teacher’s droca for all prefixes of words in 𝖲+𝖲. This task is delegated to the passive learning algorithm OPNI, which returns a droca consistent with the observed data. A droca and an observation table corresponding to it are given in Figure 5 and Figure 6 respectively (see Appendix A).

The learner then queries the teacher to verify whether the hypothesis droca accepts the same language as the target. If not, the teacher provides a counterexample, which is used to update the observation table. This process repeats until the learner synthesises a droca that is equivalent to the teacher’s.

It is instructive to contrast our approach with the MinOCA algorithm [11]. While MinOCA uses a SAT solver to solve the passive learning problem and guarantees a minimal separating droca, the use of OPNI does not provide any bound on the size of the returned automaton. As a result, OPNI may produce increasingly large automata, and the overall learning procedure OCA-L may, in principle, fail to terminate. On the other hand, reliance on SAT solvers limits the scalability of MinOCA 222This approach uses the state-of-the-art tool DFAMiner [6] which in turn uses a SAT solver to find the minimal separating dfa.. In the next section, we show that our approach, based on OPNI, significantly improves scalability compared to MinOCA.

Algorithm 3 OCA-L for droca.

Learning of VOCA

We customise the OCA-L method for learning voca as well. In this setting, the counter-actions are determined by the input alphabet and can therefore be inferred directly from the word. Consequently, the function 𝖠𝖼𝗍 does not have to be included in the observation table. This simplifies the learning process, as the sets 𝖲+ and 𝖲 constructed by OCA-L are considerably smaller. Furthermore, there are words that do not have a valid run and are denoted by x in the observation table. The notion of d-closed and d-consistent has to be modified such that an x-marked cell does not have to be compared with a cell in the same column. Moreover, the equivalence check for voca is more efficient than for droca. A voca and an observation table corresponding to it are given in Figure 7 and Figure 8 respectively (see Appendix A).

5 Experimental evaluation

Bruyère et al. [5], were the first to provide a tool for learning droca. They employ counter value queries in addition to standard membership and equivalence queries. While effective in principle, this approach does not scale well as the size of the droca being learnt increases beyond 7 states.

To address these limitations, Mathew et al. [11] introduced MinOCA, a learning tool capable of inferring droca with at most 15 states using a SAT-based approach. Although MinOCA improves upon earlier implementations, its reliance on SAT solvers leads to a significant increase in computational overhead as the size of the automaton grows. In practice, this results in a bottleneck that makes learning larger MinOCA infeasible.

In this work, we present a new approach – OCA-L– which replaces the SAT-based inference in MinOCA with OPNI (see Section 3). This scales effectively with input size and demonstrates the ability to learn larger droca, significantly outperforming existing tools.

We implemented OCA-L in Python and tested it on randomly generated droca. We also implemented a faster learning algorithm for the special case of voca. The implementation details and the results obtained are discussed in this section.

Equivalence query.

The equivalence of droca is known to be in polynomial time [4]. However, as pointed out in [11, 5], the polynomials involved are not suitable for practical applications. Mathew et al. [11] give a practical algorithm for checking the equivalence of voca and counter-synchronous droca that returns the minimal counter-example. We use their ideas in checking the equivalence of the learnt automaton in our implementation.

Generation of random benchmarks.

We generated two datasets for evaluating the performance of the proposed method.

  • Dataset1: Random droca to compare the performance of OCA-L with MinOCA.

  • Dataset2: Random voca to evaluate the performance of OCA-L for learning voca and a similar adaptation of the MinOCA algorithm.

1. Generating random droca (Dataset1). In [11], experiments were carried out on randomly generated droca. We follow the same procedure to compare our experimental results with those of [11].

The procedure is explained here for the sake of completeness. Let n be the number of states of the droca to be generated. First, we initialise the set of states Q={q1,q2,,qn}. For all qQ, we add q to the set of final states F with probability 0.5. If Q=F or F= after this step, then we restart the procedure. Otherwise, for all qQ and aΣ, we assign δ0(q,a)=(p,c) (resp. δ1(q,a)=(p,c)), with p a random state in Q and c a random counter operation in {0,+1} (resp. {0,+1,1}). The constructed droca is 𝒜=(Q,Σ,{q1},δ0,δ1,F). If the number of reachable states of 𝒜 from the initial configuration is not n, then we discard 𝒜 and restart the whole procedure. Otherwise, we output 𝒜.

We generated random droca with number of states ranging from 2 to 30 and alphabet size ranging from 2 to 5. A total of 100 droca were generated for every pair of alphabet and number of states. We reused the dataset used in [8, 11] for droca up to 15 states.

2. Generating random voca (Dataset2). For the case of voca, we use a similar procedure for generating random voca. We generate the states in the same way as above. Following this, for all aΣ, we randomly puts it in one of the sets Σcall,Σret, or Σinit. The elements in Σcall,Σret or Σinit, will respectively have +1,1 and 0 as their corresponding counter action. If there does not exist at least one symbol in Σcall and one in Σret, then we restart the whole procedure, since the language recognised will be regular. The transitions are also generated as in the case of droca. Note that the counter action c in a transition depends on whether the symbol a is in Σcall,Σret, or Σinit. The constructed voca is 𝒜=(Q,ΣcallΣretΣinit,{q1},δ0,δ1,F). If the number of reachable states of 𝒜 from the initial configuration is not n, then we discard 𝒜 and restart the whole procedure. Otherwise, we output 𝒜.

We generated random voca with number of states ranging from 10 to 100 and input alphabet size ranging from 2 to 5. A total of 10 voca were generated for every pair of input alphabet and number of states. The number of randomly generated voca was limited to 10 per configuration due to the increasing difficulty in constructing a valid automaton where all states are reachable and satisfy the remaining conditions. Moreover, our primary objective is to evaluate how well the proposed approach scales with input size. For this purpose, the selected sample size is sufficient to observe meaningful trends in performance without incurring excessive computational overhead.

Experimental results.

All the experiments were performed on an Apple M1 chip with 8GB of RAM. We implemented the proposed method (OCA-L) in Python for droca and then for the special case of voca 333The implementations of OCA-L for droca, OCA-L and MinOCA for voca, the datasets used, and the complete results generated are available at [9]. The implementation of MinOCA for droca is provided in [8]. In Figure 3(a) (resp. Figure 4(a)), the total number of languages is out of 400 (resp. 40) for each input size because, for every number of states, we generated 400 (resp. 40) random droca (resp. voca) for input alphabet sizes 2, 3, 4, and 5; to keep the visualization simple, we omitted the z-axis for alphabet size and instead aggregated the number of successfully learnt languages across all alphabet sizes for each input size – this approach is used consistently across all graphs.

Refer to caption
(a) Number of successfully learnt languages by OCA-L (Out of 400) with 5 minutes timeout.
Refer to caption
(b) The average length of the longest counter-example.
Refer to caption
(c) Average number of states in the learnt DROCA.
Refer to caption
(d) Average number of equivalence queries used.
Figure 3: Evaluation of OCA-L and MinOCA for droca on Dataset1.

1. Evaluating the performance OCA-L and MinOCA on Dataset1: We first compare the performance of OCA-L for droca with that of MinOCA [11]. A timeout of 5 minutes was allotted for both MinOCA and OCA-L for learning each droca. If the procedure times out, we discard that input and process the next one. The number of languages successfully learnt by OCA-L and MinOCA for different input sizes is depicted in Figure 3(a). The proposed method outperforms MinOCA in terms of the number of successfully learnt languages within the given timeout as the number of states increases. The averages presented in the remaining graphs are computed using only those languages that were successfully learnt. Note that the y-values for MinOCA remain zero in all graphs for input sizes with more than 15 states, as it fails to learn any language within the specified timeout.

Figure 3(b) shows the average length of the longest counter-example. Since MinOCA guarantees learning a minimal counter-synchronous droca, whereas OCA-L provides no such guarantee, the droca learnt by OCA-L typically has more states. Consequently, the length of the counterexamples also tends to be longer for OCA-L. Figure 3(c) shows the average number of states in the learnt droca. MinOCA learns a minimal counter-synchronous droca equivalent to the input. However, the droca learnt by OPNI is equivalent and counter-synchronous with respect to the input, but not minimal. Figure 3(d) shows the average number of equivalence queries used for successfully learning the input droca. We also add in Appendix B Figure 9(a) and Figure 9(b) the average number of rows and columns in the final observation table.

Note that OCA-L is a semi-algorithm; its termination is not guaranteed. However, our experimental results on randomly generated benchmarks show that it works well in practice.

Refer to caption
(a) Number of successfully learnt languages (Out of 40) with a timeout of 20 minutes.
Refer to caption
(b) The average length of the longest counter-example.
Refer to caption
(c) Average number of states in the learnt VOCA.
Refer to caption
(d) Number of equivalence queries used.
Figure 4: Evaluation of OCA-L and MinOCA for voca on Dataset2.

2. Evaluating the performance OCA-L and MinOCA on Dataset2: We now compare the performance of OCA-L for voca with that of MinOCA [11]. We note that OCA-L for voca is faster compared to OCA-L for droca. This is mainly due to the following two reasons:

  1. 1.

    faster algorithm for checking equivalence of voca, and

  2. 2.

    the input alphabet itself determines the counter actions, and therefore, step 2 and step 3 of Algorithm 2 can be skipped while passive learning voca.

A similar modification of MinOCA for voca was also implemented. A timeout of 20 minutes was allotted for both procedures for learning each voca. If the procedure times out, we discard that input and process the next one. The number of voca languages successfully learnt by OCA-L for different input sizes is shown in Figure 4(a). We observe that OCA-L is able to learn close to 50% of voca of 100 states. However, it was not able to learn any voca with more than 20 states. The averages presented in the remaining graphs are computed using only those languages that were successfully learnt. Note that the y-values for MinOCA remain zero in all graphs for input sizes with more than 20 states, as it fails to learn any language within the specified timeout.

The results of our experiments are shown in Figure 4. Figure 4(b) shows the average length of the longest counter-example. Figure 4(c) shows the average number of states in the learnt voca. Figure 4(d) shows the average number of equivalence queries used for successfully learning the input voca. In this case also, the voca learnt by MinOCA is minimal, whereas the one learnt by OCA-L is not. Figure 10(a) and Figure 10(b) (see Appendix B) show the average number of rows and columns in the final observation table.

6 Conclusion

This work focuses on passive and active learning of deterministic real-time one-counter automata (droca). Inspired by the classical RPNI algorithm, we developed a passive learning algorithm, OPNI, tailored to droca. Building on this, we showed how active learning can be guided by a sequence of passive learning tasks, and proposed an active learning method, OCA-L, which uses OPNI as a subroutine. In contrast, the state-of-the-art MinOCA algorithm employs a SAT solver for this step.

Our experiments demonstrate that OCA-L scales significantly better than MinOCA in practice. We also used OCA-L to learn visibly one-counter automata (voca), observing that it can successfully learn automata with up to 100 states. Despite its practical advantages, a limitation of OCA-L is that it does not guarantee termination on all inputs, since OPNI may return increasingly large automata in the absence of minimality guarantees.

A fundamental bottleneck – common to our approach and to prior works such as [5, 11] – is the reliance on counter-value queries. This renders the learning process a grey-box framework, in contrast to Angluin’s black-box L algorithm for finite automata. Recent work [10] has shown that active learning of droca is possible in polynomial time even without counter-value queries. However, the proposed algorithm is not practical due to the high-degree polynomials involved. An interesting direction for future work is to combine insights from the methods: OCA-L, MinOCA [11], and OL [10] to develop learning algorithms that are both theoretically efficient and practically usable.

Finally, extending these ideas to richer models such as pushdown automata – or their subclasses, such as visibly pushdown automata – offers a direction for future research.

References

  • [1] Rajeev Alur and P. Madhusudan. Visibly pushdown languages. In STOC, pages 202–211. ACM, 2004. doi:10.1145/1007352.1007390.
  • [2] Rajeev Alur and P. Madhusudan. Adding nesting structure to words. J. ACM, 56(3):16:1–16:43, 2009. doi:10.1145/1516512.1516518.
  • [3] Dana Angluin. Learning regular sets from queries and counterexamples. Inf. Comput., 75(2):87–106, 1987. doi:10.1016/0890-5401(87)90052-6.
  • [4] Stanislav Böhm and Stefan Göller. Language equivalence of deterministic real-time one-counter automata is nl-complete. In MFCS, volume 6907 of Lecture Notes in Computer Science, pages 194–205. Springer, 2011. doi:10.1007/978-3-642-22993-0_20.
  • [5] Véronique Bruyère, Guillermo A. Pérez, and Gaëtan Staquet. Learning realtime one-counter automata. In TACAS (1), volume 13243 of Lecture Notes in Computer Science, pages 244–262. Springer, 2022. doi:10.1007/978-3-030-99524-9_13.
  • [6] Daniele Dell’Erba, Yong Li, and Sven Schewe. DFAMiner: Mining minimal separating dfas from labelled samples. In FM (2), volume 14934 of Lecture Notes in Computer Science, pages 48–66. Springer, 2024. doi:10.1007/978-3-031-71177-0_4.
  • [7] Amr F. Fahmy and Robert S. Roos. Efficient learning of real time one-counter automata. In ALT, volume 997 of Lecture Notes in Computer Science, pages 25–40. Springer, 1995. doi:10.1007/3-540-60454-5_26.
  • [8] Prince Mathew. MinOCA, January 2025. doi:10.5281/zenodo.14604419.
  • [9] Prince Mathew. OCA-L*, October 2025. doi:10.5281/zenodo.17310292.
  • [10] Prince Mathew, Vincent Penelle, and A. V. Sreejith. Learning deterministic one-counter automata in polynomial time. In LICS, pages 444–457, 2025.
  • [11] Prince Mathew, Vincent Penelle, and A. V. Sreejith. Learning real-time one-counter automata using polynomially many queries. In TACAS (1), volume 15696 of Lecture Notes in Computer Science, pages 276–294. Springer, 2025. doi:10.1007/978-3-031-90643-5_14.
  • [12] Daniel Neider and Christof Löding. Learning visibly one-counter automata in polynomial time. Technical Report, RWTH Aachen, AIB-2010-02, 2010.
  • [13] José Oncina and Pedro Garcia. Inferring regular languages in polynomial updated time. In Pattern recognition and image analysis: selected papers from the IVth Spanish Symposium, pages 49–61. World Scientific, 1992.
  • [14] Leslie G. Valiant and Mike Paterson. Deterministic one-counter automata. J. Comput. Syst. Sci., 10(3):340–350, 1975. doi:10.1016/S0022-0000(75)80005-5.

Appendix A Section 4. OCA-L: OPNI-guided active learning procedure for OCA

Figure 5: A droca recognising the language {anbmm>n}. Transitions not shown go to a non-final sink state with counter-action 0.
𝖼𝖾 ϵ
Memb 𝖠𝖼𝗍

𝖱

ϵ 0 0 (0,+1,0)
a 1 0 (1,+1,1)
b 0 1 (0,0,0)
ab 0 0 (0,0,0)

𝖱Σ

aa 2 0 (1,+1,1)
ba 0 0 (0,0,0)
bb 0 1 (0,0,0)
aba 0 0 (0,0,0)
abb 0 1 (0,0,0)
Figure 6: Observation table for the droca in Figure 5. The table is 1-closed and 1-consistent. Here, 𝖱={ϵ,a,b} and 𝖢={ϵ}.
Figure 7: A voca over the alphabet {a,b}, where Σcall={a}, Σret={b} and Σint=. The voca recognises the language {anbmmn}. The transitions not shown go to a non-final sink state.
𝖼𝖾 ϵ
Memb

𝖱

ϵ 0 0
a 1 0
ab 0 1

𝖱Σ

b x x
aa 2 0
aba 1 0
abb x x
Figure 8: Observation table for the voca in Figure 7. The table is both 1-closed and 1-consistent. Here, 𝖱={ϵ,a,ab} and 𝖢={ϵ}.

Appendix B Section 5. Experimental evaluation

Refer to caption
(a) The average number of rows in the observation table.
Refer to caption
(b) The average number of columns in the observation table.
Figure 9: Evaluation of OCA-L and MinOCA for droca on Dataset1.
Refer to caption
(a) The average number of rows in the observation table.
Refer to caption
(b) The average number of columns in the observation table.
Figure 10: Evaluation of OCA-L and MinOCA for voca on Dataset2.