Repository navigation
Conversation
0e3e1e7 to
31909a6
Compare
9d68447 to
b673f5d
Compare
|
With the aim of solving the issues in https://github.com/agda/agda/projects/3, I am currently implementing into Agda the heterogeneous unification approach described in @nad's and my upcoming paper. @UlfNorell @andreasabel @jespercockx I see that you have authored large parts of Agda.TypeChecking.Conversion, which I expect to modify and extend in the process. |
7c07896 to
0cfb762
Compare
1b0de91 to
1411c7d
Compare
Fixes #4803. Previously only the Windows job was uploading that binary, which meant that the `install_agda_user.sh` script would fail.
Displays the concerned instances in case of an inconsistence instances error.
GHC 8.0 does not support the {-# COMPLETE #-} pragma,
leading to false positives.
not support completeness for ViewPatterns
# Conflicts: # src/full/Agda/Interaction/Options.hs # src/full/Agda/TypeChecking/Monad/Base.hs # src/full/Agda/TypeChecking/Primitive/Base.hs # src/full/Agda/TypeChecking/Serialise/Instances/Errors.hs # src/full/Agda/TypeChecking/SizedTypes.hs # std-lib
|
I have implemented the changes in The performance becomes 5-6% slower than Agda when typechecking the standard library I am currently working on implementing heterogeneous unification of elimination spines (step 6). This may allow us to get rid of antiunification. A working Agda with heterogeneous unification (Heterogeneous Agda) can be found in the If you have an example which either does not work properly, or becomes much slower, tell me and I can add it both to the benchmark suite and to the test suite for this branch. |
|
I have started an implementation of heterogeneous unification for spines. Current commit: 9ae5de2...vlopezj:a8f3a97 Currently the changes result in many blocked constraints. For efficiency, twins are tagged with problem ids such that when that problem is solved, both sides of the twin are heterogeneously equal. However, it often happens that the associated problem is sufficient but not necessary. A mechanism is needed so that both sides of a twin can be re-checked for equality so that the constraint does not block unnecessarily. Doing this effectively may require some mechanism for prioritizing constraints, so that new constraints are only introduced as a last resort. One option is to integrate this with the blocker mechanism, adding a special blocker which just unblocks at a later "epoch". |
e7c3f6d to
d0300e3
Compare
# Conflicts: # src/full/Agda/TypeChecking/Conversion.hs # src/full/Agda/TypeChecking/Conversion/Pure.hs # test/Fail/Issue3882.err
# Conflicts: # stack-8.0.2.yaml
# Conflicts: # src/full/Agda/TypeChecking/Conversion.hs # src/full/Agda/TypeChecking/Conversion.hs-boot # src/full/Agda/TypeChecking/Heterogeneous.hs
|
I have implemented heterogeneous unification for spines. Work done so far: https://github.com/agda/agda/compare/future-hetcon-elim Main gains:
Main issues:
Next steps:
|
|
Superseded by #5234 |
Superseded by #5234
Tracking progress and discussion on a branch for heterogeneous constraints.
This project aims to introduce the possibility of handling heterogeneous constraints in the conversion checker into Agda.
Background
Agda constraints are of the form
Γ ⊢ t ≈ u : A.These are represented internally as the
Constraintdatatype:The context Γ is carried around as
envContextin the environmentTCEnvof the type-checking monad
TCM.In the current Agda, there are situations where one of
Γ ⊢ t : AorΓ ⊢ u : Adoes not hold, which causesissues.
Heterogeneous constraints introduce a twin context and type, so that constraints can be of the form
Γ₁‡Γ₂ ⊢ t ≈ u : A‡B, withΓ₁ ⊢ t : AorΓ₂ ⊢ u : B.There are two immediate issues:
t : Aandu : Bare manipulated, it is done in the appropriate context.Approach
The plan is to gradually introduce heterogeneous unification into Agda. The idea is to introduce
the heterogeneous contexts as additional information on top of the current heterogeneous contexts.
This additional information can be used when necessary in order to avoid bugs, while ignored
in those parts of the code that have not been upgraded. We will keep an eye on performance to make
sure that it stays comparable.
Progress
By wrapping terms in a heterogeneous context in a
Het @'LHSorHet @'RHSconstructor, the Haskell typechecker will be able to point out those points in the code that need to be changed in order to handle heterogeneity.twinPidandnecessaryare a premature optimization used to determine when two sides of the context are equal.twinLHSandtwinRHScontain the left and right sides of the twin type, respectively.twinCompatis used to downgrade the twin type to a single type in those parts of the code which cannot yet handle twins.Step 3. Include the twin contexts with the constraints themselves, and add the following newtypes:
TCEnvby a heterogeneous context. Those parts of the code that are not heterogeneous-aware will access use thetwinCompatfield.--heterogeneous-constraintsis enabled, introduce a variable with twin type incompareDom.The impact on performance seems small, with no evidence of increase in CPU time or memory.
Benchmarks.
Step 6. Introduce a machinery for compareElim based on heterogeneous constraints instead of antiunification.
We aim to keep the antiunification result as the
twinCompatpart of the type.For instance, turning (ΠAB‡ΠA′B′) into Π(A‡A′)(B‡B′).
Step 7. Adapt
compareTermandcompareAtomso that they can too handle heterogeneous constraints without downgrading them. We intend to perform downgrading to homogeneous constraints in the cubical side initially, to keep the scope restricted.Step 8: Add code to check that a context is homogeneous before instantiating a metavariable.
Step 8½: Check if Issue3027 and others are now resolved, and if
we can check the examples in the technical paper.
Step 9. …
Future work
Questions (Known unknowns)
For instance, currently compareDom uses the smaller of the two types.
How does the heterogeneous equality translate to subtyping?
Journal
TCEnvpolymorphic in the type ofenvContext, so that the in the conversion algorithm one can have a twin context, those parts dealing with terms the usual one, and common parts would work in either. This quickly became unfeasible due to the dependency of big parts of the codebase on theMonadWarningmachinery, which viaMonadPretty,MonadReduceandMonadAddContextultimately requires the usual context.ValueCmpHet).Agda.Utils.Semigroupsubmodule.See second attempt. I will test an approach where a (potentially) heterogeneous context is carried around in the environment. This will hopefully allow most of the code to remain unchanged, with switching of contexts happening only where needed.
The main issue is how to handle context manipulations, but hopefully these can be fixed on a case-by-case basis.
References