Documentation

Mathlib.Lean.MessageData.Trace

Utilities for analyzing MessageData #

WARNING: The declarations in this module may become obsolete with upcoming core changes.

TraceData has no structured success/failure field. Instead, withTraceNodeBefore (in Lean.Util.Trace) prepends emoji to the rendered header message using ExceptToEmoji:

The TraceResult type and traceResultOf function provide structured access to this encoding.

Pending lean4 PRs #

These lean4 PRs may render declarations in this module obsolete:

The success/failure status of a trace node, as encoded by withTraceNodeBefore via emoji prefix on the rendered header.

Intended to match TraceResult from lean4#12698. Once that PR is available, callers should prefer td.result? over parsing the header string with traceResultOf.

  • success : TraceResult

    Header starts with ✅️ (checkEmoji)

  • failure : TraceResult

    Header starts with ❌️ (crossEmoji)

  • error : TraceResult

    Header starts with 💥️ (bombEmoji) — an exception was thrown

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Determine the status of a trace node from its rendered header string.

      Lean's withTraceNodeBefore prepends checkEmoji/crossEmoji/bombEmoji (defined in Lean.Util.Trace) to trace headers to indicate outcomes.

      The TraceResult will be recorded in trace messages directly in lean4#12698. Once that PR is available, callers should prefer td.result? over calling this function.

      Note: the emoji constants include a variation selector (U+FE0F), but String.startsWith handles this since we check for the base codepoint which is always the prefix.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Strip the leading status emoji and space from a trace header string, leaving just the semantic content for comparison across trace runs.

        Trace headers from withTraceNodeBefore have the form "{emoji}[{VS16}] {content}". This strips everything through the first space. Returns the string unchanged if no recognized status prefix is present.

        Equations
        Instances For

          Extract the instance name from a rendered apply @Foo to Goal trace header. Returns the string between "apply " and " to ".

          Note: this is fragile string matching against Lean's Meta.synthInstance trace format. If the trace format changes, this function will silently return the original string. Once lean4#12699 is available, these nodes will have trace class Meta.synthInstance.apply and can be identified structurally via td.cls instead of string-matching on the header.

          Equations
          Instances For

            Deduplicate an array of MessageData by their rendered string representations.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For