<p>Let $M=(\Sigma,S,s_0,\delta)$ be an (unknown) deterministic finite-state automaton (DFA), with alphabet $\Sigma$, statespace $S$, start state $s_0 \in S$, and transition relation $\delta$.  I want to explore $M$, i.e., visit every state of $M$, or as many states as possible.  Unfortunately, I'm not given $M$; I only have the ability to send inputs to $M$.</p>

<p>In particular, what I can do is specify some input strings $x,y,\dots \in \Sigma^*$.  The string $x$ will drive $M$ down some path, namely, down the sequence of states $s_0,s_1,s_2,\dots$ where $s_{i+1} = \delta(s_i,x_i)$.  I can specify as many input strings as I want.</p>

<p>The cost to me is the sum of the lengths of the input strings.  In other words, each transition costs me \$1.</p>

<p>The benefit to me is the fraction of $M$'s states that are visited at least once in response to at least one of these input strings.</p>

<p>I have complete freedom to choose the set of input strings, but I am not given any feedback (I can't see the sequence of states that $M$ follows, I don't learn when I've visited a new state, etc.).  I'm hoping to get as much coverage of $M$'s statespace as possible.</p>

<p>How should I choose the set of input strings to maximize the coverage while minimizing the cost?  For instance, given a fixed budget, what's the best set of input strings that will give the best benefit?  Is there a reasonable strategy, or any theory to help guide the choice of input strings?</p>

<hr>

<p>Of course, I realize that the worst-case coverage, taken over all possible DFAs, might be very poor.  But I would be satisfied with any approach that one can argue is close to optimal, in any meaningful sense.  For instance, maybe one metric might be to use a regret ratio, where the regret of strategy 1 compared to strategy 2 is the maximum, over all DFA's $M$, of the benefit of strategy 2 on $M$ divided by the benefit of strategy 1 on $M$.  Or maybe you can suggest some other way to formulate this in a principled way that admits an interesting solution.  I'm open to suggestions about how to formulate the problem in a way that permits analysis.</p>

<p>If it's helpful, I'll promise that the alphabet is small (say, $|\Sigma| \le 10$), the number of states is not too large (say, $|S| \le 1000$), and the diameter of the graph is small (say, at most 10).</p>

<p>I'm also interested in the variant where $M$ is a NFA instead of a DFA, but I thought I'd start with the simpler case. </p>

<p>This is an attempt at an application of theory to practice.  The application is randomized testing of UI-driven applications, where we think of the application as a DFA and the inputs represent user actions (e.g., tapping on a particular portion of the screen).  The problem above is an idealization of the problem where we don't get any feedback as we go (which is motivated by the fact that it's not trivial to observe anything reliable about the state of the application).</p>

CC BY-SA 3.0
2013-10-25T22:04:49.530Z
After sending an input do I get as feedback the percentage of state visited?
Marzio De Biasi
CC BY-SA 3.0
2013-10-25T22:10:45.923Z
@MarzioDeBiasi, no, you don't.  (In practice you might get some feedback, but it's very unreliable, which is why I wanted to start to see how good you can do without any feedback at all.  So I'd prefer to say "no" and see how good a solution we can get without any feedback.)
D.W.
CC BY-SA 3.0
2013-10-25T22:12:24.737Z
D.W. ok, what is exactly the "total" benefit function to maximize (it should be a function of both the transition cost, and the final percentage of covered states) ?
Marzio De Biasi
CC BY-SA 3.0
2013-10-25T22:29:14.587Z
P.S. I'm not an expert, but perhaps the problem is similar to the cover time in a Markov-chain (with n-states and equal probability on the outgoing transitions). See also cover time of DAGs (e.g. http://cstheory.stackexchange.com/questions/2908/cover-time-of-directed-graphs)
Marzio De Biasi
CC BY-SA 3.0
2013-10-25T23:26:25.717Z
I fear you may need a lot more features from this model to get good results. As an adversary, I'd pick $s$, the shortest string that doesn't appear as a prefix in your set of words. Then, I'd construct $M$ to force all inputs not containing $s$ as a prefix into a single sink state and put as many states as I'd like corresponding to strings with $s$ as a prefix. To beat this adversary, all you could do is pick your set of words to be the set of all words (of a given length).
mhum
CC BY-SA 3.0
2013-10-26T00:28:53.057Z
@mhum, yup, agreed, that's why I said the worst-case performance (i.e., taken over all $M$'s) of any fixed strategy will surely be very bad -- I was thinking of the same sort of example.  Thank you for highlighting this.  Nonetheless, I still have an intuition that some collections of strings are better than others.  Does that seem right, and is there any way to formalize this?  For instance, maybe we can normalize relative to the coverage that would be achieved by a single random walk, or something like that?
D.W.
CC BY-SA 3.0
2013-10-26T00:29:51.517Z
@MarzioDeBiasi, if you want a well-specified objective function to maximize, the formulation I would recommend is: you are given a fixed budget (an upper bound on the allowed cost), and you want to find the strategy with the best possible benefit (final coverage) subject to the restriction that you must live within your budget.
D.W.
CC BY-SA 3.0
2013-10-28T19:32:22.170Z
@D.W. Without any restriction on $M$, my feeling is that you won't be able to do any better than straight brute force (i.e.: all strings of a given length). However, it's possible that your real-life scenario may have some subtle restrictions on the structure of $M$. The adversarial argument relies on the possibility of pathologically bad $M$'s. Maybe you can introduce some criteria on $M$ to exclude such weirdness?
mhum
<ds.algorithms><application-of-theory><ai.artificial-intel><heuristics><dfa>
Exploring a DFA, with no feedback
D.W.
# Exploring a DFA, with no feedback

(Asked by: username_0 on 2013-10-25)

Let $M=(\Sigma,S,s\_0,\delta)$ be an (unknown) deterministic finite-state automaton (DFA), with alphabet $\Sigma$, statespace $S$, start state $s\_0 \in S$, and transition relation $\delta$. I want to explore $M$, i.e., visit every state of $M$, or as many states as possible. Unfortunately, I'm not given $M$; I only have the ability to send inputs to $M$.

In particular, what I can do is specify some input strings $x,y,\dots \in \Sigma^\*$. The string $x$ will drive $M$ down some path, namely, down the sequence of states $s\_0,s\_1,s\_2,\dots$ where $s\_{i+1} = \delta(s\_i,x\_i)$. I can specify as many input strings as I want.

The cost to me is the sum of the lengths of the input strings. In other words, each transition costs me \$1.

The benefit to me is the fraction of $M$'s states that are visited at least once in response to at least one of these input strings.

I have complete freedom to choose the set of input strings, but I am not given any feedback (I can't see the sequence of states that $M$ follows, I don't learn when I've visited a new state, etc.). I'm hoping to get as much coverage of $M$'s statespace as possible.

How should I choose the set of input strings to maximize the coverage while minimizing the cost? For instance, given a fixed budget, what's the best set of input strings that will give the best benefit? Is there a reasonable strategy, or any theory to help guide the choice of input strings?

---

Of course, I realize that the worst-case coverage, taken over all possible DFAs, might be very poor. But I would be satisfied with any approach that one can argue is close to optimal, in any meaningful sense. For instance, maybe one metric might be to use a regret ratio, where the regret of strategy 1 compared to strategy 2 is the maximum, over all DFA's $M$, of the benefit of strategy 2 on $M$ divided by the benefit of strategy 1 on $M$. Or maybe you can suggest some other way to formulate this in a principled way that admits an interesting solution. I'm open to suggestions about how to formulate the problem in a way that permits analysis.

If it's helpful, I'll promise that the alphabet is small (say, $|\Sigma| \le 10$), the number of states is not too large (say, $|S| \le 1000$), and the diameter of the graph is small (say, at most 10).

I'm also interested in the variant where $M$ is a NFA instead of a DFA, but I thought I'd start with the simpler case.

This is an attempt at an application of theory to practice. The application is randomized testing of UI-driven applications, where we think of the application as a DFA and the inputs represent user actions (e.g., tapping on a particular portion of the screen). The problem above is an idealization of the problem where we don't get any feedback as we go (which is motivated by the fact that it's not trivial to observe anything reliable about the state of the application).

**Tags:** ds.algorithms, application-of-theory, ai.artificial-intel, heuristics, dfa

> **Comments:**
> **username_1**: After sending an input do I get as feedback the percentage of state visited?  
> **username_0**: @MarzioDeBiasi, no, you don't.  (In practice you might get some feedback, but it's very unreliable, which is why I wanted to start to see how good you can do without any feedback at all.  So I'd prefer to say "no" and see how good a solution we can get without any feedback.)  
> **username_1**: username_0 ok, what is exactly the "total" benefit function to maximize (it should be a function of both the transition cost, and the final percentage of covered states) ?  
> **username_1**: P.S. I'm not an expert, but perhaps the problem is similar to the cover time in a Markov-chain (with n-states and equal probability on the outgoing transitions). See also cover time of DAGs (e.g. http://cstheory.stackexchange.com/questions/2908/cover-time-of-directed-graphs)  
> **username_2**: I fear you may need a lot more features from this model to get good results. As an adversary, I'd pick $s$, the shortest string that doesn't appear as a prefix in your set of words. Then, I'd construct $M$ to force all inputs not containing $s$ as a prefix into a single sink state and put as many states as I'd like corresponding to strings with $s$ as a prefix. To beat this adversary, all you could do is pick your set of words to be the set of all words (of a given length).  
> **username_0**: @username_2, yup, agreed, that's why I said the worst-case performance (i.e., taken over all $M$'s) of any fixed strategy will surely be very bad -- I was thinking of the same sort of example.  Thank you for highlighting this.  Nonetheless, I still have an intuition that some collections of strings are better than others.  Does that seem right, and is there any way to formalize this?  For instance, maybe we can normalize relative to the coverage that would be achieved by a single random walk, or something like that?  
> **username_0**: @MarzioDeBiasi, if you want a well-specified objective function to maximize, the formulation I would recommend is: you are given a fixed budget (an upper bound on the allowed cost), and you want to find the strategy with the best possible benefit (final coverage) subject to the restriction that you must live within your budget.  
> **username_2**: @username_0 Without any restriction on $M$, my feeling is that you won't be able to do any better than straight brute force (i.e.: all strings of a given length). However, it's possible that your real-life scenario may have some subtle restrictions on the structure of $M$. The adversarial argument relies on the possibility of pathologically bad $M$'s. Maybe you can introduce some criteria on $M$ to exclude such weirdness?  

---

## 0 answers

