public void MyTest() { PDLEnumerator pdlEnumerator = new PDLEnumerator(); var solver = new CharSetSolver(BitWidth.BV64); List <char> alph = new List <char> { 'a', 'b' }; HashSet <char> al = new HashSet <char>(alph); var a = solver.MkCharConstraint(false, 'a'); var b = solver.MkCharConstraint(false, 'b'); var moves = new List <Move <BDD> >(); moves.Add(new Move <BDD>(0, 1, a)); moves.Add(new Move <BDD>(0, 3, b)); moves.Add(new Move <BDD>(1, 2, b)); moves.Add(new Move <BDD>(2, 1, a)); moves.Add(new Move <BDD>(1, 1, a)); moves.Add(new Move <BDD>(2, 2, b)); moves.Add(new Move <BDD>(3, 4, a)); moves.Add(new Move <BDD>(4, 3, b)); moves.Add(new Move <BDD>(3, 3, b)); moves.Add(new Move <BDD>(4, 4, a)); var dfa1 = Automaton <BDD> .Create(0, new int[] { 0, 1, 3 }, moves).Determinize(solver).Minimize(solver); foreach (var v in pdlEnumerator.SynthesizePDL(al, dfa1, solver, new StringBuilder(), 5000)) { Console.WriteLine(PDLUtil.ToEnglishString(v)); break; } }
public override string ToString() { long enumTimeout = 1000L; #region feedback components PDLEnumerator pdlEnumerator = new PDLEnumerator(); PDLPred symmPhi = null; PDLPred underPhi = null; string posWitness = null; string negWitness = null; //If hint or solution try computing the description of the symmdiff if (level == FeedbackLevel.Hint || level == FeedbackLevel.Solution) { //Avoid formulas that are too complex var maxSize = 7; if (symmetricDifference.StateCount < 15) { foreach (var phi1 in pdlEnumerator.SynthesizePDL(alphabet, symmetricDifference, solver, new StringBuilder(), enumTimeout)) { var sizePhi1 = phi1.GetFormulaSize(); if (sizePhi1 < maxSize && !phi1.IsComplex()) { maxSize = sizePhi1; symmPhi = phi1; } } } } //Avoid empty string case and particular string if (symmPhi is PDLEmptyString || symmPhi is PDLIsString) { symmPhi = null; } //If not minimal try computing and underapprox of symmdiff if (symmPhi == null && level != FeedbackLevel.Minimal) { //Avoid formulas that are too complex var minSize = 9; if (symmetricDifference.StateCount < 15) { foreach (var phi2 in pdlEnumerator.SynthesizeUnderapproximationPDL(alphabet, symmetricDifference, solver, new StringBuilder(), enumTimeout)) { var formula = phi2.First; var sizeForm = formula.GetFormulaSize(); if (sizeForm < minSize && !formula.IsComplex()) { minSize = sizeForm; underPhi = formula; } break; } } } //Avoid empty string case and particular string if (underPhi is PDLEmptyString || underPhi is PDLIsString) { underPhi = null; } if (!positiveDifference.IsEmpty) { posWitness = DFAUtilities.GenerateShortTerm(positiveDifference, solver); } else { negWitness = DFAUtilities.GenerateShortTerm(negativeDifference, solver); } #endregion string result = ""; //string.Format("U: {0}%. ", utility); if (symmPhi != null) { if (symmPhi is PDLEmptyString) { result += "Your solution does not behave correctly on the empty string"; } else { result += string.Format("Your solution is not correct on this set of strings: <br /> <div align='center'>{0}</div>", PDLUtil.ToEnglishString(symmPhi)); } } else if (underPhi != null) { if (underPhi is PDLEmptyString) { result += "Your solution does not behave correctly on the empty string"; } else { result += string.Format("Your solution is not correct on this set of strings: <br /> <div align='center'>{0}</div>", PDLUtil.ToEnglishString(underPhi)); } } else { if (posWitness != null) { result += string.Format("Your solution does not accept the {0} while the correct solution does.", posWitness != "" ? "string '<i>" + posWitness + "</i>'" : "empty string"); } else { result += string.Format("Your solution accepts the {0} while the correct solution doesn't.", negWitness != "" ? "string '<i>" + negWitness + "</i>'" : "empty string"); } } return(result); }