LeanMachineLearning

KernelDiagram.KernelM?🔗

Definition

Given a kernel expression, return a string diagram. Otherwise none.

🔗def
KernelDiagram.KernelM? (e : Lean.Expr) : Lean.MetaM (Option ProofWidgets.Html)
KernelDiagram.KernelM? (e : Lean.Expr) : Lean.MetaM (Option ProofWidgets.Html)

Code

open scoped Jsx in def KernelM? (e : Expr) : MetaM (Option Html) := do let e instantiateMVars e try let (e, _) transformKernelToHom e [] let k StringDiagram.mkKind e let x : Option (List (List StringDiagram.Node) × List (List StringDiagram.Strand)) (match k with | .monoidal => do let some ctx BicategoryLike.mkContext? (ρ := Monoidal.Context) e | return none CoherenceM.run (ctx := ctx) do let e' := ( BicategoryLike.eval k.name ( MkMor₂.ofExpr e)).expr return some ( e'.nodes, e'.strands) | .bicategory => do let some ctx BicategoryLike.mkContext? (ρ := Bicategory.Context) e | return none CoherenceM.run (ctx := ctx) do let e' := ( BicategoryLike.eval k.name ( MkMor₂.ofExpr e)).expr return some ( e'.nodes, e'.strands) | .none => return none) match x with | none => return none | some (nodes, strands) => do DiagramBuilderM.run do StringDiagram.mkKernelDiagram nodes strands trace[string_diagram] "Penrose substance: \n{( get).sub}" match DiagramBuilderM.buildDiagram StringDiagram.dsl StringDiagram.sty with | some html => return html | none => return <span>No non-structural morphisms found.</span> catch _ => return none

Actions: Source · Open Issue

Meaning last changed in v4.34.0-rc2-1-g439785b (2026-08-23).

Self-contained, with its dependencies inlined and proofs replaced by sorry: download the raw file · open it in the Lean web editor.

Dependency graph

Audit surface: 5 project declarations, 220 external constants

✓ Proved: no sorry anywhere in its closure

This is the tool's own reading of one build's recorded axioms, and it is not robust against an author who wants it to pass. Checking meant to be relied on should go through Comparator, which replays the proof through the kernel from an export against an explicit list of permitted axioms.