fact stringlengths 6 3.84k | type stringclasses 11 values | library stringclasses 32 values | imports listlengths 1 14 | filename stringlengths 20 95 | symbolic_name stringlengths 1 90 | docstring stringlengths 7 20k ⌀ |
|---|---|---|---|---|---|---|
WhiskerRight.nodes (v h₁ h₂ : ℕ) : WhiskerRight → List Node
| WhiskerRight.of η => [.atom ⟨v, h₁, h₂, η⟩]
| WhiskerRight.whisker _ η f =>
let ηs := η.nodes v h₁ h₂
let k₁ := (ηs.map (fun n ↦ n.srcList)).flatten.length
let k₂ := (ηs.map (fun n ↦ n.tarList)).flatten.length
let s : Node := .id ⟨v, h₁ + k₁, h₂ + k₂, f⟩
ηs ++ [s] | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | WhiskerRight.nodes | The list of nodes associated with a 2-morphism. The position is counted from the
specified natural numbers. |
HorizontalComp.nodes (v h₁ h₂ : ℕ) : HorizontalComp → List Node
| HorizontalComp.of η => η.nodes v h₁ h₂
| HorizontalComp.cons _ η ηs =>
let s₁ := η.nodes v h₁ h₂
let k₁ := (s₁.map (fun n ↦ n.srcList)).flatten.length
let k₂ := (s₁.map (fun n ↦ n.tarList)).flatten.length
let s₂ := ηs.nodes v (h₁ + k₁) (h₂ + k₂)
s₁ ++ s₂ | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | HorizontalComp.nodes | The list of nodes associated with a 2-morphism. The position is counted from the
specified natural numbers. |
WhiskerLeft.nodes (v h₁ h₂ : ℕ) : WhiskerLeft → List Node
| WhiskerLeft.of η => η.nodes v h₁ h₂
| WhiskerLeft.whisker _ f η =>
let s : Node := .id ⟨v, h₁, h₂, f⟩
let ss := η.nodes v (h₁ + 1) (h₂ + 1)
s :: ss
variable {ρ : Type} [MonadMor₁ (CoherenceM ρ)] | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | WhiskerLeft.nodes | The list of nodes associated with a 2-morphism. The position is counted from the
specified natural numbers. |
topNodes (η : WhiskerLeft) : CoherenceM ρ (List Node) := do
return (← η.srcM).toList.mapIdx fun i f => .id ⟨0, i, i, f⟩ | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | topNodes | The list of nodes at the top of a string diagram. |
NormalExpr.nodesAux (v : ℕ) : NormalExpr → CoherenceM ρ (List (List Node))
| NormalExpr.nil _ α => return [(← α.srcM).toList.mapIdx fun i f => .id ⟨v, i, i, f⟩]
| NormalExpr.cons _ _ η ηs => do
let s₁ := η.nodes v 0 0
let s₂ ← ηs.nodesAux (v + 1)
return s₁ :: s₂ | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | NormalExpr.nodesAux | The list of nodes at the top of a string diagram. The position is counted from the
specified natural number. |
NormalExpr.nodes (e : NormalExpr) : CoherenceM ρ (List (List Node)) :=
match e with
| NormalExpr.nil _ _ => return []
| NormalExpr.cons _ _ η _ => return (← topNodes η) :: (← e.nodesAux 1) | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | NormalExpr.nodes | The list of nodes associated with a 2-morphism. |
pairs {α : Type} : List α → List (α × α) :=
fun l => l.zip (l.drop 1) | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | pairs | `pairs [a, b, c, d]` is `[(a, b), (b, c), (c, d)]`. |
NormalExpr.strands (e : NormalExpr) : CoherenceM ρ (List (List Strand)) := do
let l ← e.nodes
(pairs l).mapM fun (x, y) ↦ do
let xs := (x.map (fun n ↦ n.tarList)).flatten
let ys := (y.map (fun n ↦ n.srcList)).flatten
if xs.length ≠ ys.length then
throwError "The number of the start and end points of a string does not match."
(xs.zip ys).mapIdxM fun k ((n₁, f₁), (n₂, _)) => do
return ⟨n₁.hPosTar + k, n₁, n₂, f₁⟩ | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | NormalExpr.strands | The list of strands associated with a 2-morphism. |
PenroseVar : Type where
/-- The identifier of the variable. -/
ident : String
/-- The indices of the variable. -/
indices : List ℕ
/-- The underlying expression of the variable. -/
e : Expr | structure | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | PenroseVar | A type for Penrose variables. |
Node.toPenroseVar (n : Node) : PenroseVar :=
⟨"E", [n.vPos, n.hPosSrc, n.hPosTar], n.e⟩ | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | Node.toPenroseVar | The penrose variable associated with a node. |
Strand.toPenroseVar (s : Strand) : PenroseVar :=
⟨"f", [s.vPos, s.hPos], s.atom₁.e⟩
/-! ## Widget for general string diagrams -/
open ProofWidgets Penrose DiagramBuilderM Lean.Server
open scoped Jsx in | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | Strand.toPenroseVar | The penrose variable associated with a strand. |
addPenroseVar (tp : String) (v : PenroseVar) :
DiagramBuilderM Unit := do
let h := <InteractiveCode fmt={← Widget.ppExprTagged v.e} />
addEmbed (toString v) tp h | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | addPenroseVar | Add the variable `v` with the type `tp` to the substance program. |
addConstructor (tp : String) (v : PenroseVar) (nm : String) (vs : List PenroseVar) :
DiagramBuilderM Unit := do
let vs' := ", ".intercalate (vs.map (fun v => toString v))
addInstruction s!"{tp} {v} := {nm} ({vs'})"
open scoped Jsx in | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | addConstructor | Add constructor `tp v := nm (vs)` to the substance program. |
mkStringDiagram (nodes : List (List Node)) (strands : List (List Strand)) :
DiagramBuilderM PUnit := do
/- Add 2-morphisms. -/
for x in nodes.flatten do
match x with
| .atom _ => do addPenroseVar "Atom" x.toPenroseVar
| .id _ => do addPenroseVar "Id" x.toPenroseVar
/- Add constraints. -/
for l in nodes do
for (x₁, x₂) in pairs l do
addInstruction s!"Left({x₁.toPenroseVar}, {x₂.toPenroseVar})"
/- Add constraints. -/
for (l₁, l₂) in pairs nodes do
if let some x₁ := l₁.head? then
if let some x₂ := l₂.head? then
addInstruction s!"Above({x₁.toPenroseVar}, {x₂.toPenroseVar})"
/- Add 1-morphisms as strings. -/
for l in strands do
for s in l do
addConstructor "Mor1" s.toPenroseVar
"MakeString" [s.startPoint.toPenroseVar, s.endPoint.toPenroseVar] | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | mkStringDiagram | Construct a string diagram from a Penrose `sub`stance program and expressions `embeds` to
display as labels in the diagram. |
dsl :=
include_str ".."/".."/".."/"widget"/"src"/"penrose"/"monoidal.dsl" | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | dsl | Penrose dsl file for string diagrams. |
sty :=
include_str ".."/".."/".."/"widget"/"src"/"penrose"/"monoidal.sty" | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | sty | Penrose sty file for string diagrams. |
Kind where
| monoidal : Kind
| bicategory : Kind
| none : Kind | inductive | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | Kind | The kind of the context. |
Kind.name : Kind → Name
| Kind.monoidal => `monoidal
| Kind.bicategory => `bicategory
| Kind.none => default | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | Kind.name | The name of the context. |
mkKind (e : Expr) : MetaM Kind := do
let e ← instantiateMVars e
let e ← (match (← whnfR e).eq? with
| some (_, lhs, _) => return lhs
| none => return e)
let ctx? ← BicategoryLike.mkContext? (ρ := Bicategory.Context) e
match ctx? with
| some _ => return .bicategory
| none =>
let ctx? ← BicategoryLike.mkContext? (ρ := Monoidal.Context) e
match ctx? with
| some _ => return .monoidal
| none => return .none
open scoped Jsx in | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | mkKind | Given an expression, return the kind of the context. |
stringM? (e : Expr) : MetaM (Option Html) := do
let e ← instantiateMVars e
let k ← mkKind e
let x : Option (List (List Node) × List (List 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
mkStringDiagram nodes strands
trace[string_diagram] "Penrose substance: \n{(← get).sub}"
match ← DiagramBuilderM.buildDiagram dsl sty with
| some html => return html
| none => return <span>No non-structural morphisms found.</span>
open scoped Jsx in | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | stringM | Given a 2-morphism, return a string diagram. Otherwise `none`. |
mkEqHtml (lhs rhs : Html) : Html :=
<div className="flex">
<div className="w-50">
<details «open»={true}>
<summary className="mv2 pointer">String diagram for LHS</summary> {lhs}
</details>
</div>
<div className="w-50">
<details «open»={true}>
<summary className="mv2 pointer">String diagram for RHS</summary> {rhs}
</details>
</div>
</div> | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | mkEqHtml | Help function for displaying two string diagrams in an equality. |
stringEqM? (e : Expr) : MetaM (Option Html) := do
let e ← whnfR <| ← instantiateMVars e
let some (_, lhs, rhs) := e.eq? | return none
let some lhs ← stringM? lhs | return none
let some rhs ← stringM? rhs | return none
return some <| mkEqHtml lhs rhs | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | stringEqM | Given an equality between 2-morphisms, return a string diagram of the LHS and RHS.
Otherwise `none`. |
stringMorOrEqM? (e : Expr) : MetaM (Option Html) := do
forallTelescopeReducing (← whnfR <| ← inferType e) fun xs a => do
if let some html ← stringM? (mkAppN e xs) then
return some html
else if let some html ← stringEqM? a then
return some html
else
return none | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | stringMorOrEqM | Given an 2-morphism or equality between 2-morphisms, return a string diagram.
Otherwise `none`. |
@[expr_presenter]
stringPresenter : ExprPresenter where
userName := "String diagram"
layoutKind := .block
present type := do
if let some html ← stringMorOrEqM? type then
return html
throwError "Couldn't find a 2-morphism to display a string diagram."
open scoped Jsx in | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | stringPresenter | The `Expr` presenter for displaying string diagrams. |
@[server_rpc_method]
rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) :=
RequestM.asTask do
let html : Option Html ← (do
if props.goals.isEmpty then
return none
let some g := props.goals[0]? | unreachable!
g.ctx.val.runMetaM {} do
g.mvarId.withContext do
let type ← g.mvarId.getType
stringEqM? type)
match html with
| none => return <span>No String Diagram.</span>
| some inner => return inner | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | rpc | The RPC method for displaying string diagrams. |
@[widget_module]
StringDiagram : Component PanelWidgetProps :=
mk_rpc_widget% StringDiagram.rpc
open Command | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | StringDiagram | Display the string diagrams if the goal is an equality of morphisms in a monoidal category. |
@[command_elab stringDiagram, inherit_doc stringDiagram]
elabStringDiagramCmd : CommandElab := fun
| stx@`(#string_diagram $t:term) => do
let html ← runTermElabM fun _ => do
let e ← try mkConstWithFreshMVarLevels (← realizeGlobalConstNoOverloadWithInfo t)
catch _ => Term.levelMVarToParam (← instantiateMVars (← Term.elabTerm t none))
match ← StringDiagram.stringMorOrEqM? e with
| some html => return html
| none => throwError "could not find a morphism or equality: {e}"
liftCoreM <| Widget.savePanelWidgetInfo
(hash HtmlDisplay.javascript)
(return json% { html: $(← Server.RpcEncodable.rpcEncode html) })
stx
| stx => throwError "Unexpected syntax {stx}." | def | Tactic | [
"ProofWidgets.Component.PenroseDiagram",
"ProofWidgets.Component.Panel.Basic",
"ProofWidgets.Presentation.Expr",
"ProofWidgets.Component.HtmlDisplay",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Monoidal.Normalize"
] | Mathlib/Tactic/Widget/StringDiagram.lean | elabStringDiagramCmd | null |
bicategoryNf (mvarId : MVarId) : MetaM (List MVarId) := do
BicategoryLike.normalForm Bicategory.Context `bicategory mvarId
@[inherit_doc bicategoryNf]
elab "bicategory_nf" : tactic => withMainContext do
replaceMainGoal (← bicategoryNf (← getMainGoal)) | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Basic",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.PureCoherence"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Basic.lean | bicategoryNf | Normalize the both sides of an equality. |
bicategory (mvarId : MVarId) : MetaM (List MVarId) :=
BicategoryLike.main Bicategory.Context `bicategory mvarId
@[inherit_doc bicategory]
elab "bicategory" : tactic => withMainContext do
replaceMainGoal <| ← bicategory <| ← getMainGoal | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Basic",
"Mathlib.Tactic.CategoryTheory.Bicategory.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.PureCoherence"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Basic.lean | bicategory | Use the coherence theorem for bicategories to solve equations in a bicategory,
where the two sides only differ by replacing strings of bicategory structural morphisms
(that is, associators, unitors, and identities)
with different strings of structural morphisms with the same source and target.
That is, `bicategory` can handle goals of the form
`a ≫ f ≫ b ≫ g ≫ c = a' ≫ f ≫ b' ≫ g ≫ c'`
where `a = a'`, `b = b'`, and `c = c'` can be proved using `bicategory_coherence`. |
srcExpr (η : Expr) : MetaM Expr := do
match (← whnfR (← inferType η)).getAppFnArgs with
| (``Quiver.Hom, #[_, _, f, _]) => return f
| _ => throwError m!"{η} is not a morphism" | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | srcExpr | The domain of a morphism. |
tgtExpr (η : Expr) : MetaM Expr := do
match (← whnfR (← inferType η)).getAppFnArgs with
| (``Quiver.Hom, #[_, _, _, g]) => return g
| _ => throwError m!"{η} is not a morphism" | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | tgtExpr | The codomain of a morphism. |
srcExprOfIso (η : Expr) : MetaM Expr := do
match (← whnfR (← inferType η)).getAppFnArgs with
| (``Iso, #[_, _, f, _]) => return f
| _ => throwError m!"{η} is not a morphism" | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | srcExprOfIso | The domain of an isomorphism. |
tgtExprOfIso (η : Expr) : MetaM Expr := do
match (← whnfR (← inferType η)).getAppFnArgs with
| (``Iso, #[_, _, _, g]) => return g
| _ => throwError m!"{η} is not a morphism"
initialize registerTraceClass `bicategory | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | tgtExprOfIso | The codomain of an isomorphism. |
Context where
/-- The level for 2-morphisms. -/
level₂ : Level
/-- The level for 1-morphisms. -/
level₁ : Level
/-- The level for objects. -/
level₀ : Level
/-- The expression for the underlying category. -/
B : Q(Type level₀)
/-- The bicategory instance. -/
instBicategory : Q(Bicategory.{level₂, level₁} $B) | structure | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | Context | The context for evaluating expressions. |
mkContext? (e : Expr) : MetaM (Option Context) := do
let e ← instantiateMVars e
let type ← instantiateMVars <| ← inferType e
match (← whnfR (← inferType e)).getAppFnArgs with
| (``Quiver.Hom, #[_, _, f, _]) =>
let fType ← instantiateMVars <| ← inferType f
match (← whnfR fType).getAppFnArgs with
| (``Quiver.Hom, #[_, _, a, _]) =>
let B ← inferType a
let .succ level₀ ← getLevel B | return none
let .succ level₁ ← getLevel fType | return none
let .succ level₂ ← getLevel type | return none
let some instBicategory ← synthInstance?
(mkAppN (.const ``Bicategory [level₂, level₁, level₀]) #[B]) | return none
return some ⟨level₂, level₁, level₀, B, instBicategory⟩
| _ => return none
| _ => return none | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | mkContext | Populate a `context` object for evaluating `e`. |
BicategoryM := CoherenceM Context | abbrev | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | BicategoryM | The monad for the normalization of 2-morphisms. |
structuralIso_inv {f g : a ⟶ b} (η : f ≅ g) :
η.symm.hom = η.inv := by
simp only [Iso.symm_hom] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | structuralIso_inv | null |
structuralIsoOfExpr_comp {f g h : a ⟶ b}
(η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η)
(θ : g ⟶ h) (θ' : g ≅ h) (ih_θ : θ'.hom = θ) :
(η' ≪≫ θ').hom = η ≫ θ := by
simp [ih_η, ih_θ] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | structuralIsoOfExpr_comp | null |
structuralIsoOfExpr_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c}
(η : g ⟶ h) (η' : g ≅ h) (ih_η : η'.hom = η) :
(whiskerLeftIso f η').hom = f ◁ η := by
simp [ih_η] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | structuralIsoOfExpr_whiskerLeft | null |
structuralIsoOfExpr_whiskerRight {f g : a ⟶ b} (h : b ⟶ c)
(η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η) :
(whiskerRightIso η' h).hom = η ▷ h := by
simp [ih_η] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | structuralIsoOfExpr_whiskerRight | null |
StructuralOfExpr_bicategoricalComp {f g h i : a ⟶ b} [BicategoricalCoherence g h]
(η : f ⟶ g) (η' : f ≅ g) (ih_η : η'.hom = η) (θ : h ⟶ i) (θ' : h ≅ i) (ih_θ : θ'.hom = θ) :
(bicategoricalIsoComp η' θ').hom = η ⊗≫ θ := by
simp [ih_η, ih_θ, bicategoricalIsoComp, bicategoricalComp] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | StructuralOfExpr_bicategoricalComp | null |
id₁? (e : Expr) : BicategoryM (Option Obj) := do
let ctx ← read
let _bicat := ctx.instBicategory
let a : Q($ctx.B) ← mkFreshExprMVar ctx.B
if ← withDefault <| isDefEq e q(𝟙 $a) then
return some ⟨← instantiateMVars a⟩
else
return none | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | id₁ | Check that `e` is definitionally equal to `𝟙 a`. |
comp? (e : Expr) : BicategoryM (Option (Mor₁ × Mor₁)) := do
let ctx ← read
let _bicat := ctx.instBicategory
let a ← mkFreshExprMVarQ ctx.B
let b ← mkFreshExprMVarQ ctx.B
let c ← mkFreshExprMVarQ ctx.B
let f ← mkFreshExprMVarQ q($a ⟶ $b)
let g ← mkFreshExprMVarQ q($b ⟶ $c)
if ← withDefault <| isDefEq e q($f ≫ $g) then
let a ← instantiateMVars a
let b ← instantiateMVars b
let c ← instantiateMVars c
let f ← instantiateMVars f
let g ← instantiateMVars g
return some ((.of ⟨f, ⟨a⟩, ⟨b⟩⟩), .of ⟨g, ⟨b⟩, ⟨c⟩⟩)
else
return none | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | comp | Return `(f, g)` if `e` is definitionally equal to `f ≫ g`. |
partial mor₁OfExpr (e : Expr) : BicategoryM Mor₁ := do
if let some f := (← get).cache.find? e then
return f
let f ←
if let some a ← id₁? e then
MonadMor₁.id₁M a
else if let some (f, g) ← comp? e then
MonadMor₁.comp₁M (← mor₁OfExpr f.e) (← mor₁OfExpr g.e)
else
return Mor₁.of ⟨e, ⟨← srcExpr e⟩, ⟨ ← tgtExpr e⟩⟩
modify fun s => { s with cache := s.cache.insert e f }
return f | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | mor₁OfExpr | Construct a `Mor₁` expression from a Lean expression. |
partial Mor₂IsoOfExpr (e : Expr) : BicategoryM Mor₂Iso := do
match (← whnfR e).getAppFnArgs with
| (``Bicategory.associator, #[_, _, _, _, _, _, f, g, h]) =>
associatorM' (← MkMor₁.ofExpr f) (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h)
| (``Bicategory.leftUnitor, #[_, _, _, _, f]) =>
leftUnitorM' (← MkMor₁.ofExpr f)
| (``Bicategory.rightUnitor, #[_, _, _, _, f]) =>
rightUnitorM' (← MkMor₁.ofExpr f)
| (``Iso.refl, #[_, _, f]) =>
id₂M' (← MkMor₁.ofExpr f)
| (``Iso.symm, #[_, _, _, _, η]) =>
symmM (← Mor₂IsoOfExpr η)
| (``Iso.trans, #[_, _, _, _, _, η, θ]) =>
comp₂M (← Mor₂IsoOfExpr η) (← Mor₂IsoOfExpr θ)
| (``Bicategory.whiskerLeftIso, #[_, _, _, _, _, f, _, _, η]) =>
whiskerLeftM (← MkMor₁.ofExpr f) (← Mor₂IsoOfExpr η)
| (``Bicategory.whiskerRightIso, #[_, _, _, _, _, _, _, η, h]) =>
whiskerRightM (← Mor₂IsoOfExpr η) (← MkMor₁.ofExpr h)
| (``bicategoricalIsoComp, #[_, _, _, _, _, g, h, _, inst, η, θ]) =>
let α ← coherenceHomM (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h) inst
coherenceCompM α (← Mor₂IsoOfExpr η) (← Mor₂IsoOfExpr θ)
| (``BicategoricalCoherence.iso, #[_, _, _, _, f, g, inst]) =>
coherenceHomM' (← MkMor₁.ofExpr f) (← MkMor₁.ofExpr g) inst
| _ =>
return .of ⟨e, ← MkMor₁.ofExpr (← srcExprOfIso e), ← MkMor₁.ofExpr (← tgtExprOfIso e)⟩
open MonadMor₂ in | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | Mor₂IsoOfExpr | Construct a `Mor₂Iso` term from a Lean expression. |
partial Mor₂OfExpr (e : Expr) : BicategoryM Mor₂ := do
match ← whnfR e with
| .proj ``Iso 0 η => homM (← Mor₂IsoOfExpr η)
| .proj ``Iso 1 η => invM (← Mor₂IsoOfExpr η)
| .app .. => match (← whnfR e).getAppFnArgs with
| (``CategoryStruct.id, #[_, _, f]) => id₂M (← MkMor₁.ofExpr f)
| (``CategoryStruct.comp, #[_, _, _, _, _, η, θ]) =>
comp₂M (← Mor₂OfExpr η) (← Mor₂OfExpr θ)
| (``Bicategory.whiskerLeft, #[_, _, _, _, _, f, _, _, η]) =>
whiskerLeftM (← MkMor₁.ofExpr f) (← Mor₂OfExpr η)
| (``Bicategory.whiskerRight, #[_, _, _, _, _, _, _, η, h]) =>
whiskerRightM (← Mor₂OfExpr η) (← MkMor₁.ofExpr h)
| (``bicategoricalComp, #[_, _, _, _, _, g, h, _, inst, η, θ]) =>
let α ← coherenceHomM (← MkMor₁.ofExpr g) (← MkMor₁.ofExpr h) inst
coherenceCompM α (← Mor₂OfExpr η) (← Mor₂OfExpr θ)
| _ => return .of ⟨e, ← MkMor₁.ofExpr (← srcExpr e), ← MkMor₁.ofExpr (← tgtExpr e)⟩
| _ =>
return .of ⟨e, ← MkMor₁.ofExpr (← srcExpr e), ← MkMor₁.ofExpr (← tgtExpr e)⟩ | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Datatypes",
"Mathlib.Tactic.CategoryTheory.BicategoricalComp"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Datatypes.lean | Mor₂OfExpr | Construct a `Mor₂` term from a Lean expression. |
@[nolint synTaut]
evalComp_nil_nil (α : f ≅ g) (β : g ≅ h) :
(α ≪≫ β).hom = (α ≪≫ β).hom := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalComp_nil_nil | null |
evalComp_nil_cons (α : f ≅ g) (β : g ≅ h) (η : h ⟶ i) (ηs : i ⟶ j) :
α.hom ≫ (β.hom ≫ η ≫ ηs) = (α ≪≫ β).hom ≫ η ≫ ηs := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalComp_nil_cons | null |
evalComp_cons (α : f ≅ g) (η : g ⟶ h) {ηs : h ⟶ i} {θ : i ⟶ j} {ι : h ⟶ j}
(e_ι : ηs ≫ θ = ι) :
(α.hom ≫ η ≫ ηs) ≫ θ = α.hom ≫ η ≫ ι := by
simp [e_ι] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalComp_cons | null |
eval_comp
{η η' : f ⟶ g} {θ θ' : g ⟶ h} {ι : f ⟶ h}
(e_η : η = η') (e_θ : θ = θ') (e_ηθ : η' ≫ θ' = ι) :
η ≫ θ = ι := by
simp [e_η, e_θ, e_ηθ] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_comp | null |
eval_of (η : f ⟶ g) :
η = (Iso.refl _).hom ≫ η ≫ (Iso.refl _).hom := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_of | null |
eval_monoidalComp
{η η' : f ⟶ g} {α : g ≅ h} {θ θ' : h ⟶ i} {αθ : g ⟶ i} {ηαθ : f ⟶ i}
(e_η : η = η') (e_θ : θ = θ') (e_αθ : α.hom ≫ θ' = αθ) (e_ηαθ : η' ≫ αθ = ηαθ) :
η ≫ α.hom ≫ θ = ηαθ := by
simp [e_η, e_θ, e_αθ, e_ηαθ]
@[nolint synTaut] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_monoidalComp | null |
evalWhiskerLeft_nil (f : a ⟶ b) {g h : b ⟶ c} (α : g ≅ h) :
(whiskerLeftIso f α).hom = (whiskerLeftIso f α).hom := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerLeft_nil | null |
evalWhiskerLeft_of_cons
{f : a ⟶ b} {g h i j : b ⟶ c}
(α : g ≅ h) (η : h ⟶ i) {ηs : i ⟶ j} {θ : f ≫ i ⟶ f ≫ j} (e_θ : f ◁ ηs = θ) :
f ◁ (α.hom ≫ η ≫ ηs) = (whiskerLeftIso f α).hom ≫ f ◁ η ≫ θ := by
simp [e_θ] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerLeft_of_cons | null |
evalWhiskerLeft_comp
{f : a ⟶ b} {g : b ⟶ c} {h i : c ⟶ d}
{η : h ⟶ i} {η₁ : g ≫ h ⟶ g ≫ i} {η₂ : f ≫ g ≫ h ⟶ f ≫ g ≫ i}
{η₃ : f ≫ g ≫ h ⟶ (f ≫ g) ≫ i} {η₄ : (f ≫ g) ≫ h ⟶ (f ≫ g) ≫ i}
(e_η₁ : g ◁ η = η₁) (e_η₂ : f ◁ η₁ = η₂)
(e_η₃ : η₂ ≫ (α_ _ _ _).inv = η₃) (e_η₄ : (α_ _ _ _).hom ≫ η₃ = η₄) :
(f ≫ g) ◁ η = η₄ := by
simp [e_η₁, e_η₂, e_η₃, e_η₄] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerLeft_comp | null |
evalWhiskerLeft_id {η : f ⟶ g}
{η₁ : f ⟶ 𝟙 a ≫ g} {η₂ : 𝟙 a ≫ f ⟶ 𝟙 a ≫ g}
(e_η₁ : η ≫ (λ_ _).inv = η₁) (e_η₂ : (λ_ _).hom ≫ η₁ = η₂) :
𝟙 a ◁ η = η₂ := by
simp [e_η₁, e_η₂] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerLeft_id | null |
eval_whiskerLeft
{f : a ⟶ b} {g h : b ⟶ c}
{η η' : g ⟶ h} {θ : f ≫ g ⟶ f ≫ h}
(e_η : η = η') (e_θ : f ◁ η' = θ) :
f ◁ η = θ := by
simp [e_η, e_θ] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_whiskerLeft | null |
eval_whiskerRight
{f g : a ⟶ b} {h : b ⟶ c}
{η η' : f ⟶ g} {θ : f ≫ h ⟶ g ≫ h}
(e_η : η = η') (e_θ : η' ▷ h = θ) :
η ▷ h = θ := by
simp [e_η, e_θ]
@[nolint synTaut] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_whiskerRight | null |
evalWhiskerRight_nil (α : f ≅ g) (h : b ⟶ c) :
α.hom ▷ h = α.hom ▷ h := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRight_nil | null |
evalWhiskerRightAux_of {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) :
η ▷ h = (Iso.refl _).hom ≫ η ▷ h ≫ (Iso.refl _).hom := by
simp | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRightAux_of | null |
evalWhiskerRight_cons_of_of
{f g h i : a ⟶ b} {j : b ⟶ c}
{α : f ≅ g} {η : g ⟶ h} {ηs : h ⟶ i} {ηs₁ : h ≫ j ⟶ i ≫ j}
{η₁ : g ≫ j ⟶ h ≫ j} {η₂ : g ≫ j ⟶ i ≫ j} {η₃ : f ≫ j ⟶ i ≫ j}
(e_ηs₁ : ηs ▷ j = ηs₁) (e_η₁ : η ▷ j = η₁)
(e_η₂ : η₁ ≫ ηs₁ = η₂) (e_η₃ : (whiskerRightIso α j).hom ≫ η₂ = η₃) :
(α.hom ≫ η ≫ ηs) ▷ j = η₃ := by
simp_all | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRight_cons_of_of | null |
evalWhiskerRight_cons_whisker
{f : a ⟶ b} {g : a ⟶ c} {h i : b ⟶ c} {j : a ⟶ c} {k : c ⟶ d}
{α : g ≅ f ≫ h} {η : h ⟶ i} {ηs : f ≫ i ⟶ j}
{η₁ : h ≫ k ⟶ i ≫ k} {η₂ : f ≫ (h ≫ k) ⟶ f ≫ (i ≫ k)} {ηs₁ : (f ≫ i) ≫ k ⟶ j ≫ k}
{ηs₂ : f ≫ (i ≫ k) ⟶ j ≫ k} {η₃ : f ≫ (h ≫ k) ⟶ j ≫ k} {η₄ : (f ≫ h) ≫ k ⟶ j ≫ k}
{η₅ : g ≫ k ⟶ j ≫ k}
(e_η₁ : ((Iso.refl _).hom ≫ η ≫ (Iso.refl _).hom) ▷ k = η₁) (e_η₂ : f ◁ η₁ = η₂)
(e_ηs₁ : ηs ▷ k = ηs₁) (e_ηs₂ : (α_ _ _ _).inv ≫ ηs₁ = ηs₂)
(e_η₃ : η₂ ≫ ηs₂ = η₃) (e_η₄ : (α_ _ _ _).hom ≫ η₃ = η₄)
(e_η₅ : (whiskerRightIso α k).hom ≫ η₄ = η₅) :
(α.hom ≫ (f ◁ η) ≫ ηs) ▷ k = η₅ := by
simp at e_η₁ e_η₅
simp [e_η₁, e_η₂, e_ηs₁, e_ηs₂, e_η₃, e_η₄, e_η₅] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRight_cons_whisker | null |
evalWhiskerRight_comp
{f f' : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d}
{η : f ⟶ f'} {η₁ : f ≫ g ⟶ f' ≫ g} {η₂ : (f ≫ g) ≫ h ⟶ (f' ≫ g) ≫ h}
{η₃ : (f ≫ g) ≫ h ⟶ f' ≫ (g ≫ h)} {η₄ : f ≫ (g ≫ h) ⟶ f' ≫ (g ≫ h)}
(e_η₁ : η ▷ g = η₁) (e_η₂ : η₁ ▷ h = η₂)
(e_η₃ : η₂ ≫ (α_ _ _ _).hom = η₃) (e_η₄ : (α_ _ _ _).inv ≫ η₃ = η₄) :
η ▷ (g ≫ h) = η₄ := by
simp [e_η₁, e_η₂, e_η₃, e_η₄] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRight_comp | null |
evalWhiskerRight_id
{η : f ⟶ g} {η₁ : f ⟶ g ≫ 𝟙 b} {η₂ : f ≫ 𝟙 b ⟶ g ≫ 𝟙 b}
(e_η₁ : η ≫ (ρ_ _).inv = η₁) (e_η₂ : (ρ_ _).hom ≫ η₁ = η₂) :
η ▷ 𝟙 b = η₂ := by
simp [e_η₁, e_η₂] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | evalWhiskerRight_id | null |
eval_bicategoricalComp
{η η' : f ⟶ g} {α : g ≅ h} {θ θ' : h ⟶ i} {αθ : g ⟶ i} {ηαθ : f ⟶ i}
(e_η : η = η') (e_θ : θ = θ') (e_αθ : α.hom ≫ θ' = αθ) (e_ηαθ : η' ≫ αθ = ηαθ) :
η ≫ α.hom ≫ θ = ηαθ := by
simp [e_η, e_θ, e_αθ, e_ηαθ] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/Normalize.lean | eval_bicategoricalComp | null |
normalizeIsoComp {p : a ⟶ b} {f : b ⟶ c} {g : c ⟶ d} {pf : a ⟶ c} {pfg : a ⟶ d}
(η_f : p ≫ f ≅ pf) (η_g : pf ≫ g ≅ pfg) :=
(α_ _ _ _).symm ≪≫ whiskerRightIso η_f g ≪≫ η_g | abbrev | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | normalizeIsoComp | The composition of the normalizing isomorphisms `η_f : p ≫ f ≅ pf` and `η_g : pf ≫ g ≅ pfg`. |
naturality_associator
{p : a ⟶ b} {f : b ⟶ c} {g : c ⟶ d} {h : d ⟶ e} {pf : a ⟶ c} {pfg : a ⟶ d} {pfgh : a ⟶ e}
(η_f : p ≫ f ≅ pf) (η_g : pf ≫ g ≅ pfg) (η_h : pfg ≫ h ≅ pfgh) :
p ◁ (α_ f g h) ≪≫ (normalizeIsoComp η_f (normalizeIsoComp η_g η_h)) =
(normalizeIsoComp (normalizeIsoComp η_f η_g) η_h) :=
Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_associator | null |
naturality_leftUnitor {p : a ⟶ b} {f : b ⟶ c} {pf : a ⟶ c} (η_f : p ≫ f ≅ pf) :
p ◁ (λ_ f) ≪≫ η_f = normalizeIsoComp (ρ_ p) η_f :=
Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_leftUnitor | null |
naturality_rightUnitor {p : a ⟶ b} {f : b ⟶ c} {pf : a ⟶ c} (η_f : p ≫ f ≅ pf) :
p ◁ (ρ_ f) ≪≫ η_f = normalizeIsoComp η_f (ρ_ pf) :=
Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_rightUnitor | null |
naturality_id {p : a ⟶ b} {f : b ⟶ c} {pf : a ⟶ c} (η_f : p ≫ f ≅ pf) :
p ◁ Iso.refl f ≪≫ η_f = η_f :=
Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_id | null |
naturality_comp {p : a ⟶ b} {f g h : b ⟶ c} {pf : a ⟶ c} {η : f ≅ g} {θ : g ≅ h}
(η_f : p ≫ f ≅ pf) (η_g : p ≫ g ≅ pf) (η_h : p ≫ h ≅ pf)
(ih_η : p ◁ η ≪≫ η_g = η_f) (ih_θ : p ◁ θ ≪≫ η_h = η_g) :
p ◁ (η ≪≫ θ) ≪≫ η_h = η_f := by
rw [← ih_η, ← ih_θ]
apply Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_comp | null |
naturality_whiskerLeft {p : a ⟶ b} {f : b ⟶ c} {g h : c ⟶ d} {pf : a ⟶ c} {pfg : a ⟶ d}
{η : g ≅ h} (η_f : p ≫ f ≅ pf) (η_fg : pf ≫ g ≅ pfg) (η_fh : pf ≫ h ≅ pfg)
(ih_η : pf ◁ η ≪≫ η_fh = η_fg) :
p ◁ (f ◁ η) ≪≫ normalizeIsoComp η_f η_fh = normalizeIsoComp η_f η_fg := by
rw [← ih_η]
apply Iso.ext (by simp [← whisker_exchange_assoc]) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_whiskerLeft | null |
naturality_whiskerRight {p : a ⟶ b} {f g : b ⟶ c} {h : c ⟶ d} {pf : a ⟶ c} {pfh : a ⟶ d}
{η : f ≅ g} (η_f : p ≫ f ≅ pf) (η_g : p ≫ g ≅ pf) (η_fh : pf ≫ h ≅ pfh)
(ih_η : p ◁ η ≪≫ η_g = η_f) :
p ◁ (η ▷ h) ≪≫ normalizeIsoComp η_g η_fh = normalizeIsoComp η_f η_fh := by
rw [← ih_η]
apply Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_whiskerRight | null |
naturality_inv {p : a ⟶ b} {f g : b ⟶ c} {pf : a ⟶ c}
{η : f ≅ g} (η_f : p ≫ f ≅ pf) (η_g : p ≫ g ≅ pf) (ih : p ◁ η ≪≫ η_g = η_f) :
p ◁ η.symm ≪≫ η_f = η_g := by
rw [← ih]
apply Iso.ext (by simp) | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | naturality_inv | null |
of_normalize_eq {f g f' : a ⟶ b} {η θ : f ≅ g} (η_f : 𝟙 a ≫ f ≅ f') (η_g : 𝟙 a ≫ g ≅ f')
(h_η : 𝟙 a ◁ η ≪≫ η_g = η_f)
(h_θ : 𝟙 a ◁ θ ≪≫ η_g = η_f) : η = θ := by
apply Iso.ext
calc
η.hom = (λ_ f).inv ≫ η_f.hom ≫ η_g.inv ≫ (λ_ g).hom := by
simp [← reassoc_of% (congrArg Iso.hom h_η)]
_ = θ.hom := by
simp [← reassoc_of% (congrArg Iso.hom h_θ)] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | of_normalize_eq | null |
mk_eq_of_naturality {f g f' : a ⟶ b} {η θ : f ⟶ g} {η' θ' : f ≅ g}
(η_f : 𝟙 a ≫ f ≅ f') (η_g : 𝟙 a ≫ g ≅ f')
(Hη : η'.hom = η) (Hθ : θ'.hom = θ)
(Hη' : whiskerLeftIso (𝟙 a) η' ≪≫ η_g = η_f)
(Hθ' : whiskerLeftIso (𝟙 a) θ' ≪≫ η_g = η_f) : η = θ :=
calc
η = η'.hom := Hη.symm
_ = (λ_ f).inv ≫ η_f.hom ≫ η_g.inv ≫ (λ_ g).hom := by
simp [← reassoc_of% (congrArg Iso.hom Hη')]
_ = θ'.hom := by
simp [← reassoc_of% (congrArg Iso.hom Hθ')]
_ = θ := Hθ | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | mk_eq_of_naturality | null |
pureCoherence (mvarId : MVarId) : MetaM (List MVarId) :=
BicategoryLike.pureCoherence Bicategory.Context `bicategory mvarId
@[inherit_doc pureCoherence]
elab "bicategory_coherence" : tactic => withMainContext do
replaceMainGoal <| ← Bicategory.pureCoherence <| ← getMainGoal | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.Tactic.CategoryTheory.Bicategory.Datatypes"
] | Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean | pureCoherence | Close the goal of the form `η.hom = θ.hom`, where `η` and `θ` are 2-isomorphisms made up only of
associators, unitors, and identities.
```lean
example {B : Type} [Bicategory B] {a : B} :
(λ_ (𝟙 a)).hom = (ρ_ (𝟙 a)).hom := by
bicategory_coherence
``` |
mk_eq {α : Type _} (a b a' b' : α) (ha : a = a') (hb : b = b') (h : a' = b') : a = b := by
simp [h, ha, hb] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | mk_eq | null |
normalForm (ρ : Type) [Context ρ]
[MonadMor₁ (CoherenceM ρ)]
[MonadMor₂Iso (CoherenceM ρ)]
[MonadNormalExpr (CoherenceM ρ)] [MkEval (CoherenceM ρ)]
[MkMor₂ (CoherenceM ρ)]
[MonadMor₂ (CoherenceM ρ)]
(nm : Name) (mvarId : MVarId) : MetaM (List MVarId) := do
mvarId.withContext do
let e ← instantiateMVars <| ← mvarId.getType
withTraceNode nm (fun _ => return m!"normalize: {e}") do
let some (_, e₁, e₂) := (← whnfR <| ← instantiateMVars <| e).eq?
| throwError "{nm}_nf requires an equality goal"
let ctx : ρ ← mkContext e₁
CoherenceM.run (ctx := ctx) do
let e₁' ← MkMor₂.ofExpr e₁
let e₂' ← MkMor₂.ofExpr e₂
let e₁'' ← eval nm e₁'
let e₂'' ← eval nm e₂'
let H ← mkAppM ``mk_eq #[e₁, e₂, e₁''.expr.e.e, e₂''.expr.e.e, e₁''.proof, e₂''.proof]
mvarId.apply H
universe v u | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | normalForm | Transform an equality between 2-morphisms into the equality between their normalizations. |
mk_eq_of_cons {C : Type u} [CategoryStruct.{v} C]
{f₁ f₂ f₃ f₄ : C}
(α α' : f₁ ⟶ f₂) (η η' : f₂ ⟶ f₃) (ηs ηs' : f₃ ⟶ f₄)
(e_α : α = α') (e_η : η = η') (e_ηs : ηs = ηs') :
α ≫ η ≫ ηs = α' ≫ η' ≫ ηs' := by
simp [e_α, e_η, e_ηs] | theorem | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | mk_eq_of_cons | null |
ofNormalizedEq (mvarId : MVarId) : MetaM (List MVarId) := do
mvarId.withContext do
let e ← instantiateMVars <| ← mvarId.getType
let some (_, e₁, e₂) := (← whnfR e).eq? | throwError "requires an equality goal"
match (← whnfR e₁).getAppFnArgs, (← whnfR e₂).getAppFnArgs with
| (``CategoryStruct.comp, #[_, _, _, _, _, α, η]),
(``CategoryStruct.comp, #[_, _, _, _, _, α', η']) =>
match (← whnfR η).getAppFnArgs, (← whnfR η').getAppFnArgs with
| (``CategoryStruct.comp, #[_, _, _, _, _, η, ηs]),
(``CategoryStruct.comp, #[_, _, _, _, _, η', ηs']) =>
let e_α ← mkFreshExprMVar (← Meta.mkEq α α')
let e_η ← mkFreshExprMVar (← Meta.mkEq η η')
let e_ηs ← mkFreshExprMVar (← Meta.mkEq ηs ηs')
let x ← mvarId.apply (← mkAppM ``mk_eq_of_cons #[α, α', η, η', ηs, ηs', e_α, e_η, e_ηs])
return x
| _, _ => throwError "failed to make a normalized equality for {e}"
| _, _ => throwError "failed to make a normalized equality for {e}" | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | ofNormalizedEq | Split the goal `α ≫ η ≫ ηs = α' ≫ η' ≫ ηs'` into `α = α'`, `η = η'`, and `ηs = ηs'`. |
List.splitEvenOdd {α : Type u} : List α → List α × List α
| [] => ([], [])
| [a] => ([a], [])
| a::b::xs =>
let (as, bs) := List.splitEvenOdd xs
(a::as, b::bs) | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | List.splitEvenOdd | List.splitEvenOdd [0, 1, 2, 3, 4] = ([0, 2, 4], [1, 3]) |
main (ρ : Type) [Context ρ] [MonadMor₁ (CoherenceM ρ)] [MonadMor₂Iso (CoherenceM ρ)]
[MonadNormalExpr (CoherenceM ρ)] [MkEval (CoherenceM ρ)] [MkMor₂ (CoherenceM ρ)]
[MonadMor₂ (CoherenceM ρ)] [MonadCoherehnceHom (CoherenceM ρ)]
[MonadNormalizeNaturality (CoherenceM ρ)] [MkEqOfNaturality (CoherenceM ρ)]
(nm : Name) (mvarId : MVarId) : MetaM (List MVarId) :=
mvarId.withContext do
let mvarIds ← normalForm ρ nm mvarId
let (mvarIdsCoherence, mvarIdsRefl) := List.splitEvenOdd (← repeat' ofNormalizedEq mvarIds)
for mvarId in mvarIdsRefl do mvarId.refl
let mvarIds'' ← mvarIdsCoherence.mapM fun mvarId => do
withTraceNode nm (fun _ => do return m!"goal: {← mvarId.getType}") do
try
pureCoherence ρ nm mvarId
catch _ => return [mvarId]
return mvarIds''.flatten | def | Tactic | [
"Mathlib.Tactic.CategoryTheory.Coherence.Normalize",
"Mathlib.Tactic.CategoryTheory.Coherence.PureCoherence",
"Mathlib.CategoryTheory.Category.Basic"
] | Mathlib/Tactic/CategoryTheory/Coherence/Basic.lean | main | The core function for `monoidal` and `bicategory` tactics. |
Obj where
/-- Extracts a lean expression from an `Obj` term. Return `none` in the monoidal
category context. -/
e? : Option Expr
deriving Inhabited | structure | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Obj | Expressions for objects. |
Obj.e (a : Obj) : Expr :=
a.e?.get! | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Obj.e | Extract a lean expression from an `Obj` term. |
Atom₁ : Type where
/-- Extract a lean expression from an `Atom₁` term. -/
e : Expr
/-- The domain of the 1-morphism. -/
src : Obj
/-- The codomain of the 1-morphism. -/
tgt : Obj
deriving Inhabited | structure | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Atom₁ | Expressions for atomic 1-morphisms. |
MkAtom₁ (m : Type → Type) where
/-- Construct a `Atom₁` term from a lean expression. -/
ofExpr (e : Expr) : m Atom₁ | class | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | MkAtom₁ | A monad equipped with the ability to construct `Atom₁` terms. |
Mor₁ : Type
/-- `id e a` is the expression for `𝟙 a`, where `e` is the underlying lean expression. -/
| id (e : Expr) (a : Obj) : Mor₁
/-- `comp e f g` is the expression for `f ≫ g`, where `e` is the underlying lean expression. -/
| comp (e : Expr) : Mor₁ → Mor₁ → Mor₁
/-- The expression for an atomic 1-morphism. -/
| of : Atom₁ → Mor₁
deriving Inhabited | inductive | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₁ | Expressions for 1-morphisms. |
MkMor₁ (m : Type → Type) where
/-- Construct a `Mor₁` term from a lean expression. -/
ofExpr (e : Expr) : m Mor₁ | class | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | MkMor₁ | A monad equipped with the ability to construct `Mor₁` terms. |
Mor₁.e : Mor₁ → Expr
| .id e _ => e
| .comp e _ _ => e
| .of a => a.e | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₁.e | The underlying lean expression of a 1-morphism. |
Mor₁.src : Mor₁ → Obj
| .id _ a => a
| .comp _ f _ => f.src
| .of f => f.src | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₁.src | The domain of a 1-morphism. |
Mor₁.tgt : Mor₁ → Obj
| .id _ a => a
| .comp _ _ g => g.tgt
| .of f => f.tgt | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₁.tgt | The codomain of a 1-morphism. |
Mor₁.toList : Mor₁ → List Atom₁
| .id _ _ => []
| .comp _ f g => f.toList ++ g.toList
| .of f => [f] | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₁.toList | Converts a 1-morphism into a list of its components. |
MonadMor₁ (m : Type → Type) where
/-- The expression for `𝟙 a`. -/
id₁M (a : Obj) : m Mor₁
/-- The expression for `f ≫ g`. -/
comp₁M (f g : Mor₁) : m Mor₁ | class | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | MonadMor₁ | A monad equipped with the ability to manipulate 1-morphisms. |
CoherenceHom where
/-- The underlying lean expression of a coherence isomorphism. -/
e : Expr
/-- The domain of a coherence isomorphism. -/
src : Mor₁
/-- The codomain of a coherence isomorphism. -/
tgt : Mor₁
/-- The `BicategoricalCoherence` instance. -/
inst : Expr
/-- Extract the structural 2-isomorphism. -/
unfold : Expr
deriving Inhabited | structure | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | CoherenceHom | Expressions for coherence isomorphisms (i.e., structural 2-morphisms
given by `BicategoricalCoherence.iso`). |
AtomIso where
/-- The underlying lean expression of an `AtomIso` term. -/
e : Expr
/-- The domain of a 2-isomorphism. -/
src : Mor₁
/-- The codomain of a 2-isomorphism. -/
tgt : Mor₁
deriving Inhabited | structure | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | AtomIso | Expressions for atomic non-structural 2-isomorphisms. |
StructuralAtom : Type
/-- The expression for the associator `α_ f g h`. -/
| associator (e : Expr) (f g h : Mor₁) : StructuralAtom
/-- The expression for the left unitor `λ_ f`. -/
| leftUnitor (e : Expr) (f : Mor₁) : StructuralAtom
/-- The expression for the right unitor `ρ_ f`. -/
| rightUnitor (e : Expr) (f : Mor₁) : StructuralAtom
| id (e : Expr) (f : Mor₁) : StructuralAtom
| coherenceHom (α : CoherenceHom) : StructuralAtom
deriving Inhabited | inductive | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | StructuralAtom | Expressions for atomic structural 2-morphisms. |
Mor₂Iso : Type where
| structuralAtom (α : StructuralAtom) : Mor₂Iso
| comp (e : Expr) (f g h : Mor₁) (η θ : Mor₂Iso) : Mor₂Iso
| whiskerLeft (e : Expr) (f g h : Mor₁) (η : Mor₂Iso) : Mor₂Iso
| whiskerRight (e : Expr) (f g : Mor₁) (η : Mor₂Iso) (h : Mor₁) : Mor₂Iso
| horizontalComp (e : Expr) (f₁ g₁ f₂ g₂ : Mor₁) (η θ : Mor₂Iso) : Mor₂Iso
| inv (e : Expr) (f g : Mor₁) (η : Mor₂Iso) : Mor₂Iso
| coherenceComp (e : Expr) (f g h i : Mor₁) (α : CoherenceHom) (η θ : Mor₂Iso) : Mor₂Iso
| of (η : AtomIso) : Mor₂Iso
deriving Inhabited | inductive | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | Mor₂Iso | Expressions for 2-isomorphisms. |
MonadCoherehnceHom (m : Type → Type) where
/-- Unfold a coherence isomorphism. -/
unfoldM (α : CoherenceHom) : m Mor₂Iso | class | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | MonadCoherehnceHom | A monad equipped with the ability to unfold `BicategoricalCoherence.iso`. |
StructuralAtom.e : StructuralAtom → Expr
| .associator e .. => e
| .leftUnitor e .. => e
| .rightUnitor e .. => e
| .id e .. => e
| .coherenceHom α => α.e
open MonadMor₁
variable {m : Type → Type} [Monad m] | def | Tactic | [
"Lean.Meta.Basic",
"Mathlib.Init"
] | Mathlib/Tactic/CategoryTheory/Coherence/Datatypes.lean | StructuralAtom.e | The underlying lean expression of a 2-isomorphism. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.