Skip to content

[ cubical ] Boundary-sensitive elaboration - #6053

Closed
plt-amy wants to merge 6 commits into
masterfrom
aliao/boundary-sensitive-elaboration
Closed

plt-amy wants to merge 6 commits into
masterfrom
aliao/boundary-sensitive-elaboration

Conversation

@plt-amy

@plt-amy plt-amy commented Aug 26, 2022 •

Copy link
Copy Markdown
Contributor

Refactors the type checker to keep track of cubical constraints as a dedicated field in the TCEnv. The constraints associated with any given metavariable are printed in the goal, as before, but their precise representation allows us to e.g. reify the boundary as a Sub type (implemented as agda2-goal-type-as-sub). Going under introduction forms refines the boundary with the corresponding elimination.

Super WIP, no attention has been paid to making sure tests still pass, boundaries in goal types are printed with their internal representation rather than a user-facing representation, etc, etc.

TODO (off the top of my head):

  • Can I really axe IApplyConfluence like that? Probably not. Let's only call it when there's ≥2 definitions in the mutual block: that way we can be sure that it still works for mutual higher recursion, but for the most common case, we get a nice boundary and no yellow. IApplyConfluence lives again (it just uses the Boundary machinery to get better error messages)
  • Replace hcomp-and-friends' magical type-checking rules with boundary constraints
  • Refine the boundary when going into record constructors, record literals and record updates
  • Understand interaction between boundaries and pattern lambdas
  • Automated tests for everything
  • Expose a reflection primitive to reify the boundary (fixes Cubical: User-friendly usage of HLevel proofs #6009)

Mosquito nuke: this fixes #6017, but I need to make the error term less absolutely massive. "Fixes" #5884 since the boundary at any interaction point can be reified to a Sub-type. Supersedes #5999 and closes #5997.

@plt-amy plt-amy added type: enhancement Issues and pull requests about possible improvements ux: error reporting Issues to do with how Agda reports errors cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp labels Aug 26, 2022
@plt-amy plt-amy self-assigned this Aug 26, 2022
@plt-amy

plt-amy commented Aug 26, 2022

Copy link
Copy Markdown
Contributor Author

Error message from #6017 w/ the current implementation:

~ i₁ ∨ i₁ != (~ i₁ ∨ i₁) ∨ ~ i₂ ∨ i₂ of type I
when checking the boundary condition
(i = i0) ⊢ primHComp
           (λ i₂ .o →
              primTransp
              (λ i₃ →
                 primHComp
                 (λ j →
                    primPOr (~ i₁ ∨ i₁) (~ i₃ ∧ ~ i₂)
                    ((λ { i₄ (i₁ = i0) → p i0 ; i₄ (i₁ = i1) → p i₄ }) ((i₃ ∨ i₂) ∧ j))
                    (λ .o₁ → p i₁))
                 (p i₁)
                 ≡
                 primHComp
                 (λ j →
                    primPOr (~ i₁ ∨ i₁) (~ i₃ ∧ ~ i₂)
                    ((λ { i₄ (i₁ = i0) → p i0 ; i₄ (i₁ = i1) → p i₄ }) ((i₃ ∨ i₂) ∧ j))
                    (λ .o₁ → p i₁))
                 (p i₁))
              i₂ (f ((λ { i₃ (i₁ = i0) → p i0 ; i₃ (i₁ = i1) → p i₃ }) i₂ _)))
           (primTransp
            (λ i₂ →
               primHComp
               (λ j →
                  primPOr (~ i₁ ∨ i₁) (~ i₂)
                  ((λ { i₃ (i₁ = i0) → p i0 ; i₃ (i₁ = i1) → p i₃ }) (i₂ ∧ j))
                  (λ .o → p i₁))
               (p i₁)
               ≡
               primHComp
               (λ j →
                  primPOr (~ i₁ ∨ i₁) (~ i₂)
                  ((λ { i₃ (i₁ = i0) → p i0 ; i₃ (i₁ = i1) → p i₃ }) (i₂ ∧ j))
                  (λ .o → p i₁))
               (p i₁))
            i0 refl) = refl

@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch 2 times, most recently from 434d395 to 2817b99 Compare August 27, 2022 03:46
@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch from 2817b99 to 66d88d8 Compare August 31, 2022 19:54
@plt-amy

plt-amy commented Aug 31, 2022

Copy link
Copy Markdown
Contributor Author

Y'know I was expecting CI to fail on the previous commit but I wasn't expecting it to fail so fast

@plt-amy plt-amy added the refactor Changes to the code base which do not affect users (not in changelog) label Aug 31, 2022
@plt-amy

plt-amy commented Aug 31, 2022 •

Copy link
Copy Markdown
Contributor Author

Putting this here as a note to myself: There's a recurring problem that I really need to minimize, but line 278 in ZCohomology/GroupStructure always causes unsolved metas when the boundary checks aren't postponed. Like, I've had literally this same issue before.. at least I recognised it before spending hours and hours debugging

@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch from 98a628f to 5001294 Compare September 4, 2022 17:11
@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch from 5001294 to 9025104 Compare September 27, 2022 16:06
@plt-amy

plt-amy commented Sep 30, 2022

Copy link
Copy Markdown
Contributor Author

@Mergifyio rebase

@mergify

mergify Bot commented Sep 30, 2022

Copy link
Copy Markdown

rebase

✅ Branch has been successfully rebased

@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch from 9025104 to b2dc725 Compare September 30, 2022 17:26
fixup! path boundary scoping

fixup! interaction boundary printing
* pre-compute faces in normaliseBoundary
* use boundary machinery in IApplyConfluence
* discard boundary when checking all term formers
* mark LHS-induced boundary constraints as being hints only (they're
  handled by IApplyConfluence)
* Pretty instances for BoundaryConstraint

fixup! only compute dfs for iapplyconfluence

fixup! block discardAndCheck on type
@plt-amy
plt-amy force-pushed the aliao/boundary-sensitive-elaboration branch from e0e2adb to 6484432 Compare November 10, 2022 14:37
@plt-amy plt-amy closed this Mar 14, 2023
@andreasabel

Copy link
Copy Markdown
Member

Closed in favor of

@plt-amy
plt-amy deleted the aliao/boundary-sensitive-elaboration branch March 17, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp refactor Changes to the code base which do not affect users (not in changelog) type: enhancement Issues and pull requests about possible improvements ux: error reporting Issues to do with how Agda reports errors

Projects

None yet

2 participants