Add bicategory solver and coherence lemmas#606
Conversation
|
(I haven't looked at the code yet)
Cat.Bi.Base is already a nightmare module so let's not put anything else in there. |
|
I realized it should be possible to handle the interchange law without involving any variables, by just placing left whiskerings before right ones, basically. I might give it a try, but it would require fairly big changes to the representation of normal forms |
I have implemented this now, and it seems to be working well. Unfortunately, the soundness proofs for the new additions (especially the function |
|
Teaser of the solver in action, when defining the composition of lax transformations: lx .ν-compositor {a = a} {b} {c} f g =
ν .η (f B.⊗ g) ∘ H.γ→ f g ◀ (α.σ a ⊗ β.σ a) ≡⟨ bicat! C ⟩
α← _ _ _ ∘ α.σ c ▶ β.ν→ (f B.⊗ g) ∘ α→ _ _ _
∘ ⌜ α.ν→ (f B.⊗ g) ∘ H.γ→ f g ◀ α.σ a ⌝ ◀ β.σ a ∘ α← _ _ _ ≡⟨ ap! (α.ν-compositor f g) ⟩
α← _ _ _ ∘ α.σ c ▶ β.ν→ (f B.⊗ g) ∘ α→ _ _ _
∘ (α.σ c ▶ G.γ→ f g ∘ α→ _ _ _ ∘ α.ν→ f ◀ G.₁ g
∘ α← _ _ _ ∘ H.₁ f ▶ α.ν→ g ∘ α→ _ _ _) ◀ β.σ a ∘ α← _ _ _ ≡⟨ bicat! C ⟩
α← _ _ _ ∘ α.σ c ▶ ⌜ β.ν→ (f B.⊗ g) ∘ G.γ→ f g ◀ β.σ a ⌝ ∘ α→ _ _ _
∘ α→ _ _ _ ◀ β.σ a ∘ (α.ν→ f ◀ G.₁ g) ◀ β.σ a ∘ α← _ _ _ ◀ β.σ a
∘ (H.₁ f ▶ α.ν→ g) ◀ β.σ a ∘ α→ _ _ _ ◀ β.σ a ∘ α← _ _ _ ≡⟨ ap! (β.ν-compositor f g) ⟩
α← _ _ _ ∘ α.σ c ▶
(β.σ c ▶ F.γ→ f g ∘ α→ _ _ _ ∘ β.ν→ f ◀ F.₁ g
∘ α← _ _ _ ∘ G.₁ f ▶ β.ν→ g ∘ α→ _ _ _) ∘ α→ _ _ _
∘ α→ _ _ _ ◀ β.σ a ∘ (α.ν→ f ◀ G.₁ g) ◀ β.σ a ∘ α← _ _ _ ◀ β.σ a
∘ (H.₁ f ▶ α.ν→ g) ◀ β.σ a ∘ α→ _ _ _ ◀ β.σ a ∘ α← _ _ _ ≡⟨ bicat! C ⟩
(α.σ c ⊗ β.σ c) ▶ F.γ→ f g ∘ α→ _ _ _ ∘ ν .η f ◀ F.₁ g
∘ α← _ _ _ ∘ H.₁ f ▶ ν .η g ∘ α→ _ _ _ ∎Not wanting to do these by hand is what prompted me to write this solver 😅 |
@aathn Unfortunately most of the overhead seems to be from the cubical parts of the coverage checker (inventing clauses for the But if we make the necessary changes so that I'll do the rest of the work and toss you a patch in a bit. |
|
Here: https://gist.github.com/plt-amy/14b0587e2f9093ade7a40ffb6b7336b1 The next worst thing is the definition of |
|
Also looking at your code sample makes me think that we should probably make |
|
@plt-amy That's amazing, thank you! A question: I thought |
|
I find that whenever I try to cram things into |
|
I see! I changed to |
There was a problem hiding this comment.
This is pretty fantastic work, thank you! I think I'm still going to wait for @TOTBWF's opinion on the evaluation strategy since he's the solver expert, but this looks great to me.
I'm fine with either SSet or Typeω. (Also, I was kinda just doing the Typeω refactor on autopilot, so I might've missed some style-guide nitpicks… Sorry.)
I'm not sure, for pedagogical purposes I think it's often better for them to be explicit, although of course it clutters things when you have a big goal. Something that would certainly make it more convenient to work with bicategories is to make |
|
Also,
I think our position is that the reflection code is exempt from prose requirements, but, since this solver does basically prove something nontrivial about bicategories (coherence), it might still be a good idea to have it.
Yeah, we've also considered this in the past. It feels kinda nasty, but I think everything past and including the composition functor probably needs to be exploded. For now, we can improve on the display of module unitor-l {a} {b} = Cr._≅_ _ (unitor-l {a} {b})
module unitor-r {a} {b} = Cr._≅_ _ (unitor-r {a} {b})
private
open module λ← {a b} = _=>_ (unitor-l.from {a} {b}) renaming (η to λ←) using () public
open module λ→ {a b} = _=>_ (unitor-l.to {a} {b}) renaming (η to λ→) using () public
open module ρ← {a b} = _=>_ (unitor-r.from {a} {b}) renaming (η to ρ←) using () public
open module ρ→ {a b} = _=>_ (unitor-r.to {a} {b}) renaming (η to ρ→) using () publicEverything that takes a tuple is sorta beyond what we can solve without changes upstream. |
|
Well, I mean, you can also replace open module α→ {a b c d} = _=>_ (associator.to {a} {b} {c} {d}) renaming (η to α→) using () public
open module α← {a b c d} = _=>_ (associator.from {a} {b} {c} {d}) renaming (η to α←) using () publicbut this requires making it take a tuple argument everywhere (on the bright side, |
TOTBWF
left a comment
There was a problem hiding this comment.
This is amazing, thank you! I did have some high-level questions about the code, especially the frame stuff.
|
@aathn Can you add a test case for the situation described in your latest commit, something that passes only with this ordering from |
Right whiskerings are ordered highest, and can always commute with left whiskerings, but not always with associators. This means that we must order associators above left whiskerings to avoid situations where commuting an associator and a left whiskering blocks a right whiskering coming from behind from making progress.
Description
This PR adds a solver for bicategory 2-cells, indirectly proving the coherence theorem for bicategories. It also adds a module Cat.Bi.Reasoning with some useful lemmas for bicategories including coherence lemmas.
As commented in Cat.Bi.Solver, the solver currently cannot solve goals involving the interchange law on opaque 2-cells. Support for this could be added by using the variable machinery in Reflection.Variables to sort the normal forms, but then the normal forms must be extended to explicitly represent whiskerings.
There is no prose at the moment. I figure it would be good to have prose in the end, but I didn't have time to write it yet, and wanted to make the PR first to get some feedback.
I'm not sure whether Cat.Bi.Reasoning is a good place for the coherence lemmas to live, or if they should be in Cat.Bi.Base, for example.
Checklist
Before submitting a merge request, please check the items below:
support/sort-imports.hs(ornix run --experimental-features nix-command -f . sort-imports).If your change affects many files without adding substantial content, and
you don't want your name to appear on those pages (for example, treewide
refactorings or reformattings), start the commit message and PR title with
chore:.