public override void SummaryInfo(InfoPanelContent content) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("Term Info:\n"); content.switchToDefaultFormat(); content.Append("\nIdentifier: " + id).Append('\n'); content.Append("Number of Children: " + Args.Length).Append('\n'); }
public override void SummaryInfo(InfoPanelContent content) { content.switchFormat(PrintConstants.TitleFont, PrintConstants.instantiationTitleColor); content.Append("Instantiation ").Append('@').Append(LineNo + ":\n"); content.switchToDefaultFormat(); content.Append('\n').Append(Quant.PrintName).Append('\n'); content.Append("Depth: " + depth).Append('\n'); content.Append($"Longest Subpath Length: {DeepestSubpathDepth.ToString("F")}\n"); content.Append("Cost: ").Append(Cost.ToString("F")).Append("\n\n"); }
public override void InfoPanelText(InfoPanelContent content, PrettyPrintFormat format) { foreach (Literal l in Literals) { content.Append(l + "\n"); } }
public void printName(InfoPanelContent content, PrettyPrintFormat format) { content.Append(Name); if (format.showType) { content.Append(GenericType); } if (iterationOffset > 0) { content.Append("_-" + iterationOffset); } if (format.showTermId) { content.Append("[" + (id >= 0 ? id.ToString() : "g" + -id) + (isPrime ? "'" : "") + "]"); } }
public void PrettyPrint(InfoPanelContent content, PrettyPrintFormat format, int eqNumber = -1) { var numberingString = eqNumber == -1 ? "" : $"({eqNumber}) "; content.switchToDefaultFormat(); content.Append(numberingString); source.PrettyPrint(content, format, numberingString.Length); EqualityExplanationPrinter.singleton.visit(this, Tuple.Create(content, format, false, numberingString.Length)); }
/// <summary> /// Prints a section explaining the equality substitutions necessary to obtain a term matching the trigger. /// </summary> public void PrintEqualitySubstitution(InfoPanelContent content, PrettyPrintFormat format) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("\nSubstituting equalities yields:\n\n"); content.switchToDefaultFormat(); foreach (var blamedTerm in BlamedEffectiveTerms) { blamedTerm.highlightTemporarily(format, PrintConstants.blameColor); } foreach (var boundTerm in BoundEffectiveTerms) { boundTerm.highlightTemporarily(format, PrintConstants.bindColor); } foreach (var pair in EffectiveBlameTerms.Zip(fullPattern.Args, Tuple.Create)) { var effectiveTerm = pair.Item1; var usedPattern = pair.Item2; var rootTerm = equalities.FirstOrDefault(eq => eq.Key == usedPattern).Value?.FirstOrDefault(eqSource => TopLevelTerms.Contains(eqSource.Item2))?.Item2 ?? effectiveTerm; var topLevelTermNumber = format.termNumbers.First(kv => kv.Key.isSubterm(rootTerm.id)); var usedEqualityNumbers = equalities.Keys.Where(k => usedPattern.isSubterm(k)).Select(k => bindings[k]) .Select(b => { #if !DEBUG try { #endif return(format.equalityNumbers.First(kv => Term.semanticTermComparer.Equals(kv.Key.target, b.Item2)).Value); #if !DEBUG } catch (Exception) { return(0); } #endif }).Distinct(); content.Append($"Substituting ({String.Join("), (", usedEqualityNumbers)}) in ({topLevelTermNumber.Value}):\n"); effectiveTerm.PrettyPrint(content, format); content.Append("\n\n"); content.switchToDefaultFormat(); } }
public override void InfoPanelText(InfoPanelContent content, PrettyPrintFormat format) { if (Conflict != null) { Conflict.InfoPanelText(content, format); } else { content.Append("No conflict"); } }
private void addPrefix(PrintRule rule, InfoPanelContent content, ICollection <int> breakIndices) { var prefix = rule.prefix(isPrime); content.Append(prefix); if (!string.IsNullOrWhiteSpace(prefix) && rule.prefixLineBreak == PrintRule.LineBreakSetting.After) { breakIndices.Add(content.Length); } }
private void addSuffix(PrintRule rule, InfoPanelContent content, ICollection <int> breakIndices) { var suffix = rule.suffix(isPrime); content.switchFormat(rule.font ?? PrintConstants.DefaultFont, rule.color); if (!string.IsNullOrWhiteSpace(suffix) && rule.suffixLineBreak == PrintRule.LineBreakSetting.Before) { breakIndices.Add(content.Length); } content.Append(suffix); }
private void addInfix(PrintRule rule, InfoPanelContent content, ICollection <int> breakIndices) { content.switchFormat(PrintConstants.DefaultFont, rule.color); if (rule.infixLineBreak == PrintRule.LineBreakSetting.Before) { breakIndices.Add(content.Length); } content.Append(rule.infix(isPrime)); if (rule.infixLineBreak == PrintRule.LineBreakSetting.After) { breakIndices.Add(content.Length); } }
public override void SummaryInfo(InfoPanelContent content) { content.switchFormat(PrintConstants.TitleFont, PrintConstants.instantiationTitleColor); content.Append("Quantifier Info:\n"); content.switchToDefaultFormat(); content.Append("\nPrint name: ").Append(PrintName).Append('\n'); content.Append("QId: ").Append(Qid).Append('\n'); content.Append("Number of Instantiations: " + Instances.Count).Append('\n'); content.Append("Cost: " + Cost).Append('\n'); content.Append("Number of Conflicts: " + GeneratedConflicts).Append("\n\n"); }
/// <summary> /// Prints a message in the left panel. /// </summary> /// <param name="message"> The message to be displayed </param> public void DisplayMessage(string message) { // We have an additional UI update Interlocked.Increment(ref workCounter); // Must run on the main (UI) thread if (InvokeRequired) { Invoke((MethodInvoker) delegate { uiUpdateTimer.Start(); }); } else { uiUpdateTimer.Start(); } // Enqueue the message var messageContent = new InfoPanelContent(); messageContent.Append(message); messageContent.finalize(); infoPanelQueue.Enqueue(messageContent); }
public void printNoMatchdisclaimer(InfoPanelContent content) { content.switchFormat(PrintConstants.ItalicFont, PrintConstants.warningTextColor); content.Append("No pattern match found. Possible reasons include (hidden) equalities\nand / or automatic term simplification.\n"); content.switchToDefaultFormat(); }
private bool PrettyPrint(InfoPanelContent content, Stack <Color> indentFormats, PrettyPrintFormat format) { var printRule = format.getPrintRule(this); var parentRule = format.GetParentPrintRule(); var isMultiline = false; var breakIndices = new List <int>(); var startLength = content.Length; var needsParenthesis = this.needsParenthesis(format, printRule, parentRule); content.switchFormat(printRule.font ?? PrintConstants.DefaultFont, printRule.color); // check for cutoff if (format.MaxTermPrintingDepth == 1) { if (ContainsGeneralization()) { content.switchFormat(printRule.font ?? PrintConstants.DefaultFont, PrintConstants.generalizationColor); content.Append(">...<"); } else { content.Append("..."); } return(false); } if (printRule.indent) { indentFormats.Push(printRule.color); } if (needsParenthesis) { content.Append('('); } addPrefix(printRule, content, breakIndices); if (printChildren(format, printRule)) { for (var i = 0; i < Args.Length; i++) { var t = Args[i]; // Note: DO NOT CHANGE ORDER (-> short circuit) isMultiline = t.PrettyPrint(content, indentFormats, format.NextTermPrintingDepth(this, i)) || isMultiline; if (i < Args.Length - 1) { addInfix(printRule, content, breakIndices); } } } addSuffix(printRule, content, breakIndices); if (needsParenthesis) { content.Append(')'); } // are there any lines to break? var lineBreaks = linebreaksNecessary(content, format, isMultiline && (breakIndices.Count > 0), startLength); if (lineBreaks) { addLinebreaks(printRule, content, indentFormats, breakIndices); } else if (printRule.indent) { // just remove indent if necessary indentFormats.Pop(); } return(lineBreaks); }
public override void InfoPanelText(InfoPanelContent content, PrettyPrintFormat format) { SummaryInfo(content); content.Append("Highlighted terms are "); if (bindingInfo.IsPatternMatch()) { content.switchFormat(PrintConstants.DefaultFont, PrintConstants.patternMatchColor); content.Append("matched"); content.switchToDefaultFormat(); content.Append(" or "); content.switchFormat(PrintConstants.DefaultFont, PrintConstants.equalityColor); content.Append(PrintConstants.LargeTextMode ? "matched using\nequality" : "matched using equality"); content.switchToDefaultFormat(); content.Append(" or "); } content.switchFormat(PrintConstants.DefaultFont, PrintConstants.blameColor); content.Append("blamed"); content.switchToDefaultFormat(); content.Append(" or "); content.switchFormat(PrintConstants.DefaultFont, PrintConstants.bindColor); content.Append("bound"); content.switchToDefaultFormat(); content.Append(".\n\n"); tempHighlightBlameBindTerms(format); if (!bindingInfo.IsPatternMatch()) { content.switchFormat(PrintConstants.BoldFont, PrintConstants.instantiationTitleColor); if (InstantiationMethod == "theory-solving") { content.Append($"Instantiated by the {Quant.Namespace} theory solver.\n\n"); } else { content.Append($"Instantiated using {InstantiationMethod}.\n\n"); } content.switchToDefaultFormat(); if (bindingInfo.explicitlyBlamedTerms.Any()) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("Blamed Terms:\n"); content.switchToDefaultFormat(); } var termNumbering = 1; foreach (var t in bindingInfo.explicitlyBlamedTerms) { if (!format.termNumbers.TryGetValue(t, out var termNumber)) { termNumber = termNumbering; ++termNumbering; format.termNumbers[t] = termNumber; } var numberingString = $"({termNumber}) "; content.Append($"\n{numberingString}"); t.PrettyPrint(content, format, numberingString.Length); content.switchToDefaultFormat(); content.Append("\n\n"); } } if (bindingInfo.IsPatternMatch()) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("Blamed Terms:\n\n"); content.switchToDefaultFormat(); var termNumbering = 1; var blameTerms = bindingInfo.getDistinctBlameTerms(); var distinctBlameTerms = blameTerms.Where(req => bindingInfo.TopLevelTerms.Contains(req) || (!bindingInfo.equalities.SelectMany(eq => eq.Value).Any(t => t.Item2.id == req.id) && !bindingInfo.equalities.Keys.Any(k => bindingInfo.bindings[k].Item2 == req))); foreach (var t in distinctBlameTerms) { if (!format.termNumbers.TryGetValue(t, out var termNumber)) { termNumber = termNumbering; ++termNumbering; format.termNumbers[t] = termNumber; } var numberingString = $"({termNumber}) "; content.Append($"\n{numberingString}"); t.PrettyPrint(content, format, numberingString.Length); content.switchToDefaultFormat(); content.Append("\n\n"); } if (bindingInfo.equalities.Count > 0) { var numberOfTopLevelTerms = bindingInfo.getDistinctBlameTerms().Count; content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("\nRelevant equalities:\n\n"); content.switchToDefaultFormat(); format.printContextSensitive = false; foreach (var equality in bindingInfo.equalities) { var effectiveTerm = bindingInfo.bindings[equality.Key].Item2; foreach (var term in equality.Value.Select(t => t.Item2).Distinct(Term.semanticTermComparer)) { EqualityExplanation explanation; #if !DEBUG try { #endif explanation = bindingInfo.EqualityExplanations.First(ee => ee.source.id == term.id && ee.target.id == effectiveTerm.id); #if !DEBUG } catch (Exception) { explanation = new TransitiveEqualityExplanation(term, effectiveTerm, new EqualityExplanation[0]); } #endif if (!format.equalityNumbers.TryGetValue(explanation, out var termNumber)) { termNumber = termNumbering; ++termNumbering; format.equalityNumbers[explanation] = termNumber; } if (format.ShowEqualityExplanations) { explanation.PrettyPrint(content, format, termNumber); } else { var numberingString = $"({termNumber}) "; content.switchToDefaultFormat(); content.Append(numberingString); var indentString = $"¦{String.Join("", Enumerable.Repeat(" ", numberingString.Length - 1))}"; term.PrettyPrint(content, format, numberingString.Length); content.switchToDefaultFormat(); content.Append($"\n{indentString}= (explanation omitted)\n{indentString}"); effectiveTerm.PrettyPrint(content, format, numberingString.Length); } content.Append("\n\n"); } } format.printContextSensitive = true; bindingInfo.PrintEqualitySubstitution(content, format); } } if (Bindings.Any()) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("Binding information:"); content.switchToDefaultFormat(); foreach (var bindings in bindingInfo.getBindingsToFreeVars()) { content.Append("\n\n"); content.Append(bindings.Key.PrettyName).Append(" was bound to:\n"); bindings.Value.PrettyPrint(content, format); content.switchToDefaultFormat(); } } if (Quant.BodyTerm != null) { content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("\n\n\nThe quantifier body:\n\n"); content.switchToDefaultFormat(); Quant.BodyTerm.PrettyPrint(content, format); content.Append("\n\n"); } format.restoreAllOriginalRules(); content.switchToDefaultFormat(); content.switchFormat(PrintConstants.SubtitleFont, PrintConstants.sectionTitleColor); content.Append("The resulting term:\n\n"); content.switchToDefaultFormat(); concreteBody.PrettyPrint(content, format); format.restoreAllOriginalRules(); }
public override void InfoPanelText(InfoPanelContent content, PrettyPrintFormat format) { SummaryInfo(content); content.Append('\n'); PrettyPrint(content, new Stack <Color>(), format); }
public virtual void SummaryInfo(InfoPanelContent content) { content.Append("No summary available."); }