// private void runUnderapproxTest(string testName) { PDLEnumerator pdlEnumerator = new PDLEnumerator(); int printLimit = 10; CharSetSolver solver = new CharSetSolver(BitWidth.BV64); var dfa_al = ReadDFA(testName, solver); //PrintDFA(dfa_al.Second, "A", dfa_al.First); StringBuilder sb = new StringBuilder(); int i = 0; foreach (var pair in pdlEnumerator.SynthesizeUnderapproximationPDL(dfa_al.First, dfa_al.Second, solver, sb, timeout)) { i++; pair.First.ToString(sb); sb.AppendLine(" ### +" + pair.Second.ToString() + " ### +" + pair.First.GetFormulaSize()); sb.AppendLine(); if (i == printLimit) { break; } } System.Console.WriteLine(sb); }
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); }