/** Checks if a PTA constructed is consistent with provided sequences. */
 private void checkPTAConsistency(
     PTASequenceEngine engine, Set<List<Label>> sequences, boolean accept) {
   SequenceSet initSeq = engine.new SequenceSet();
   initSeq.setIdentity();
   int leafNumber = engine.getDebugDataMapDepth(null).size();
   // Now we check the consistency
   for (List<Label> seq : sequences) {
     SequenceSet endOfSeq =
         initSeq.crossWithSequence(seq); // this is aimed to follow a path in a PTA
     // to a state which is not necessarily a tail-state (hence no use calling
     // getDebugDataMapDepth(null),
     // but can inadvertently add a new sequence, hence we have to check that it has to happened at
     // the end.
     Map<String, String> map = engine.getDebugDataMapDepth(endOfSeq);
     assert map.size() == 1 : "expected size of 1, got " + map.size();
     String attrs = map.values().iterator().next();
     // For reject-sequences,
     // If the end of the sequence is not a leaf, it should be considered an accept-sequence, hence
     // throw.
     // If the end of the sequence is a leaf but should be returned, this is also an
     // accept-sequence (see the sequence engine construction above) throw.
     // The only remaining case is that the end is a leaf and should not be returned - this is ok.
     if (!accept && !attrs.equals(DebugDataValues.booleanToString(true, false)))
       throw new IllegalArgumentException(
           "reject-sequence " + seq + " is present in PTA with a positive ending");
     // For accept-sequences, the only erroneous case is when a leaf is not returned.
     // (we assume that non-leaf is always returned.)
     if (accept && attrs.equals(DebugDataValues.booleanToString(true, false)))
       throw new IllegalArgumentException(
           "reject-sequence " + seq + " is present in PTA with a negative ending");
   }
   Assert.assertEquals(leafNumber, engine.getDebugDataMapDepth(null).size());
 }