Esempio n. 1
0
 /// <summary>
 /// Generate up to k random witnesses accepted by the PDA. If the language is empty
 /// then the enumeration is empty. If k is 0 or negative then the enumeration is unbounded.
 /// Repetitions may occur.
 /// </summary>
 public IEnumerable <T[]> GenerateWitnesses(int k = 0)
 {
     if (this.automaton.IsEmpty)
     {
         yield break;
     }
     else
     {
         var ra = new ReachabilityAutomaton(this, false);
         foreach (var witness in ra.GenerateWitnesses(k))
         {
             yield return(witness.ToArray());
         }
     }
 }
Esempio n. 2
0
 bool IsNonempty_helper(out T[] witness, bool canonical)
 {
     if (this.automaton.IsEmpty)
     {
         witness = null;
         return(false);
     }
     else
     {
         var ra       = new ReachabilityAutomaton(this, canonical);
         var witness1 = ra.GetWitness();
         if (witness1 == null)
         {
             witness = null;
             return(false);
         }
         else
         {
             witness = witness1.ToArray();
             return(true);
         }
     }
 }