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 IEnumerable <Term> Transitive(TransitiveEqualityExplanation target, object arg)
 {
     return(target.equalities.SelectMany(ee => visit(ee, arg)));
 }
Esempio n. 3
0
 public abstract R Transitive(TransitiveEqualityExplanation target, A arg);