Skip to content

Boundary scavenging - #6529

Merged
plt-amy merged 8 commits into
masterfrom
aliao/ip-boundary
Mar 14, 2023
Merged

plt-amy merged 8 commits into
masterfrom
aliao/ip-boundary

Conversation

@plt-amy

@plt-amy plt-amy commented Mar 13, 2023 •

Copy link
Copy Markdown
Contributor

Third time's the charm?

Closes #5997, closes #5900, closes #3605, closes #3690. As proposed in #5997, boundary constraints are recovered during unification, before bailing in assignMeta'. If the meta assignment failed because the meta spine had endpoints (i0/i1) on it, we invert the spine anyway, but add the RHS as a boundary constraint. Inverting the meta spine is necessary to put all the RHS-es collected during unification in the same context: the top-level context. When printing, we apply the RHS-es (represented by lambdas) to the meta's context.

The boundary of an interaction point in context Γ is a Map (IntMap Bool) Term; the Term is guaranteed to be headed by (at least) as many lambdas as there are variables in Γ. Higher-order situations, eg. funext before introducing the point argument, can lead to extra lambdas. Each IntMap Bool has its keysSet a subset of the I-typed variables in Γ.

Since we store the face constraints as keyed by variables in the actual meta context (instead of in an arbitrary closure), it's trivial to implement #3690. I changed the boundary display to look like the following when running Cmd_goal_type_context_infer w/ a non-empty interaction point.

A
———— Boundary (wanted) —————————————————————————————————————
k = i0 ⊢ x
k = i1 ⊢ p j
j = i0 ⊢ ?2 (p = p) (q = q) (i = i0) (k = k)
j = i1 ⊢ ?3 (p = p) (q = q) (i = i0) (k = k)

A
———— Boundary (actual) —————————————————————————————————————
k = i0 ⊢ x
k = i1 ⊢ p j
j = i0 ⊢ x
j = i1 ⊢ p k

Demo from a week or so ago:

goal-boundary-want-have.mp4

Overview of changes:

  • Added isFaceConstraint, tryAddBoundary to MetaVars.hs. These turn equational problems into boundary constraints (according to the scheme I proposed in Collect interaction point boundaries while elaborating right-hand-sides? #5997)
  • IPBoundary is now a newtype of that Map type I mentioned, the user sees a list of IPFace' instead. getIPBoundary in BasicOps.hs is responsible for turning that boundary into a list of IPFace's in the right context. Boundaries are associated with the IP instead of the IPClause.
  • Unsolved constraints that satisfy isFaceConstraint are not reported as UnsolvedConstraints warnings, but as InteractionMetaBoundaries instead (getAllUnsolvedWarnings in Pretty/Warnings.hs)
  • IApplyConfluence doesn't have to invent IPBoundaries anymore.

plt-amy added 6 commits March 13, 2023 15:15
Any constraints that got picked up by boundary scavenging don't need to
show up in the unsolved list, especially since the unsolved list can get
*huge* when cubes are involved
When having e.g. a Path value in a constraint with boundary constraints,
η-conversion for paths meant the value had a constraint on the *next
variable to be introduced* (the negative first variable!).

We don't consider these boundary constraints anymore, since they will be
reported as soon as the user actually refines the goal.
The previous "hide boundaries" patch was far too aggreesive and ended up
silencing some constraints that had nothing to do with cubes. This fixes
that.
5 new interaction test cases for boundary scavenging + fixes the old
tests.
@plt-amy plt-amy changed the title Aliao/ip boundary Boundary scavenging Mar 13, 2023
@plt-amy plt-amy self-assigned this Mar 13, 2023
@plt-amy plt-amy added ux: interaction Issues to do with interactive development (holes, case splitting, etc) cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp labels Mar 13, 2023
@plt-amy plt-amy added this to the 2.6.4 milestone Mar 13, 2023
@plt-amy

plt-amy commented Mar 13, 2023

Copy link
Copy Markdown
Contributor Author

Twice today I got a CI failure on a nontrivial change because the left fish is not in scope... one would have thought I would have learned

@plt-amy
plt-amy force-pushed the aliao/ip-boundary branch from 6634879 to 22adf26 Compare March 13, 2023 21:55

@andreasabel andreasabel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! A PR with video demo! A new level of PR motivation!

I just skimmed the text, noticing a few stylistic changes. If it is not too much effort, would you mind putting them into a separate commit, or for some, revert them maybe? (Depending how strongly you feel about them.)

Comment thread src/full/Agda/Interaction/JSONTop.hs Resolved
Comment thread src/full/Agda/Interaction/JSONTop.hs Resolved
@plt-amy

plt-amy commented Mar 14, 2023

Copy link
Copy Markdown
Contributor Author

All but one of those changes were from partially reverting an attempt to make interestingConstraint more accurate --- so I don't mind reverting them fully 🙂

@plt-amy
plt-amy merged commit 8717a71 into master Mar 14, 2023
@plt-amy
plt-amy deleted the aliao/ip-boundary branch March 14, 2023 16:18
@andreasabel

Copy link
Copy Markdown
Member

@plt-amy : Consider adding some advertisement to CHANGELOG.

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 ux: interaction Issues to do with interactive development (holes, case splitting, etc)

Projects

None yet

2 participants