New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving blocked terms loses the user-written code #4067
Comments
The culprit here is the way we handle blocked terms. When the user writes a term This makes constraint solving more robust, according to this comment: agda/src/full/Agda/TypeChecking/MetaVars.hs Lines 391 to 394 in 4af7b92
However, I can't construct an example were it makes an important difference. Disabling it makes I'll turn it off and run through the complete test suite. |
Doing that means we lose the user-written term, for a minor chance that unification might make progress solving the twin meta.
Test suite goes through, but I get a bunch of unsolved constraints in http://www.cse.chalmers.se/~nad/repos/equality/ (master@da311d9). @nad can you check the Some of them might print funny (e.g. |
That file is easy to fix, just replace cong (_ ,_) (trans (sym $ subst-refl _ _) (subst-refl _ _)) ≡⟨ cong (cong _) (trans-symˡ _) ⟩ with the following line (and add cong (_ ,_) (trans (sym $ subst-refl _ _) (subst-refl _ _)) ≡⟨ cong (cong (proj₁ p ,_)) (trans-symˡ _) ⟩ However, fixing the lemma dcong≡hcong :
{x≡y : x P.≡ y} (f : (x : A) → B x) →
dcong f (_↔_.from ≡↔≡ x≡y) ≡ _↔_.from subst≡↔[]≡ (P.hcong f x≡y)
dcong≡hcong {B = B} {x≡y = x≡y} f =
dcong f (_↔_.from ≡↔≡ x≡y) ≡⟨ sym $ _↔_.from-to (inverse subst≡↔subst≡) {!dcong≡dcong!} ⟩
_↔_.from subst≡↔subst≡ (P.dcong f x≡y) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $ P.dcong≡hcong f ⟩
_↔_.from (subst≡↔subst≡ {B = B})
(PB._↔_.to (P.heterogeneous↔homogeneous _) (P.hcong f x≡y)) ≡⟨⟩
_↔_.from subst≡↔[]≡ (P.hcong f x≡y) ∎ If I fill the hole with the given term, then Agda quickly accepts the code. However, reloading takes a lot of time, or fails to terminate. |
An aside: If I turn on |
I opened a new ticket for the issue with |
This might be worthwhile, but since it's a non-trivial change of the internals I'm not comfortable doing it so close to the release. Also, it's not really a regression. Different versions of Agda will just drop the user code in different cases, so bumping it to 2.6.2 is the right move. |
Is it time to go ahead with this change now? Here is another test case: {-# OPTIONS --cubical #-}
open import Agda.Builtin.Cubical.Path
postulate
trans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
infix -1 finally
infixr -2 _≡⟨⟩_
_≡⟨⟩_ : {A : Set} (x {y} : A) → x ≡ y → x ≡ y
_ ≡⟨⟩ x≡y = x≡y
finally : {A : Set} (x y : A) → x ≡ y → x ≡ y
finally _ _ x≡y = x≡y
syntax finally x y x≡y = x ≡⟨ x≡y ⟩∎ y ∎
⟨_⟩ : {A : Set} → A → A
⟨ x ⟩ = x
{-# NOINLINE ⟨_⟩ #-}
record R (F : Set → Set) : Set₁ where
field
p : {A : Set} {x : F A} → x ≡ x
open R ⦃ … ⦄ public
test :
{F : Set → Set} ⦃ r : R F ⦄ {A : Set} {x₁ x₂ : F A}
(p₁ p₂ : x₁ ≡ x₂) (assumption : p₁ ≡ p₂) →
trans p p₁ ≡ trans p p₂
test p₁ p₂ assumption =
trans p p₁ ≡⟨⟩
trans p ⟨ p₁ ⟩ ≡⟨ ? ⟩∎
trans p p₂ ∎ |
I'm trying to merge the master branch into the issue4067 branch. |
@vlopezj, how would Tog handle this situation? |
I'm not convinced that it makes sense to fix this issue by making constraint solving less robust. However, I do think it makes sense to preserve user-written code. Is it possible to construct an example in which Agda replaces code ( |
Done. |
I saw that
I used |
@nad can you get the constraints from |
|
Doing that means we lose the user-written term, for a minor chance that unification might make progress solving the twin meta.
As far as I can tell the problems with cubical are legit. We block some occurrences of |
Consider the following code:
The three goal types:
Note that the final goal contains
x
instead of⟨ x ⟩
. This is unfortunate, because some tactics rely on being able to mark subterms in this way (see, for instance, Bradley Hardy's (@bch29) library holes).This is a regression, Agda 2.5.4.2 computes the following goal types:
The text was updated successfully, but these errors were encountered: