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:

@[deprecated Lean.TraceResult (since := "2026-03-23")]

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
    @[deprecated Lean.TraceData.result? (since := "2026-03-23")]
    def Lean.MessageData.traceResultOf (headerStr : String) :

    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.

    Instances For
      @[deprecated Lean.TraceData (since := "2026-03-23")]

      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.

      Instances For
        def Lean.MessageData.extractInstName (s : String) :
        String

        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.

        Instances For
          def Lean.MessageData.dedupByString (msgs : Array MessageData) :
          BaseIO (Array MessageData)

          Deduplicate an array of MessageData by their rendered string representations.

          Instances For