Skip to content
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

Remove unused pattern constructor A.AnnP #7390

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Remove unused pattern constructor A.AnnP #7390

merged 1 commit into from
Jul 24, 2024

Conversation

andreasabel
Copy link
Member

@andreasabel andreasabel commented Jul 23, 2024

Original introduced in PR #5006 commit 22e9a12

See also:

@andreasabel andreasabel linked an issue Jul 23, 2024 that may be closed by this pull request
@andreasabel andreasabel added the type: task Concerning the development of Agda (not in changelog) label Jul 23, 2024
@andreasabel andreasabel self-assigned this Jul 23, 2024
@andreasabel andreasabel added this to the 2.8.0 milestone Jul 23, 2024
@andreasabel
Copy link
Member Author

andreasabel commented Jul 23, 2024

This PR triggers a regression in the type checker.
The type argument B = A tt to the defStrictEquiv macro is no longer inferred:
https://github.com/agda/cubical/blob/6d6870cbf537294fc3fdf9c5a34909bde30ba914/Cubical/Data/Sigma/Properties.agda#L333
@jespercockx Do you have some intuition as to why this happens?

@andreasabel andreasabel added the reflection Elaborator reflection, macros, tactic arguments label Jul 23, 2024
@andreasabel
Copy link
Member Author

andreasabel commented Jul 23, 2024

Here is an extracted test case:

{-# OPTIONS --safe --cubical #-}

open import Agda.Primitive using (Level) renaming (Set to Type; _⊔_ to ℓ-max)
open import Agda.Primitive.Cubical using (PathP)
  renaming ( primIMin to _∧_  -- I → I → I
           ; primIMax to _∨_  -- I → I → I
           ; primINeg to ~_   -- I → I
           )

open import Agda.Builtin.Cubical.Glue using ( equiv-proof ; _≃_ )
open import Agda.Builtin.Cubical.Path using (_≡_)
open import Agda.Builtin.List using (List; []; _∷_)
open import Agda.Builtin.Sigma using (Σ; _,_; fst; snd)
open import Agda.Builtin.Unit using (tt) renaming ( ⊤ to Unit )

import Agda.Builtin.Reflection as R

private
  variable
    ℓ ℓ' ℓ'' : Level
    A : Type ℓ
    B : A  Type ℓ
    C : (a : A)  B a  Type ℓ
    x y : A

refl : x ≡ x
refl {x = x} _ = x
{-# INLINE refl #-}

cong : (f : (a : A)  B a) (p : x ≡ y) 
       PathP (λ i  B (p i)) (f x) (f y)
cong f p i = f (p i)
{-# INLINE cong #-}

fiber :  {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A  B) (y : B)  Type (ℓ-max ℓ ℓ')
fiber {A = A} f y = Σ A λ x  f x ≡ y

strictContrFibers :  {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {f : A  B} (g : B  A) (b : B)
   Σ (fiber f (f (g b))) λ t 
    ((t' : fiber f b)  PathP (λ _  fiber f (f (g b))) t (g (f (t' .fst)) , cong (λ x  f (g x)) (t' .snd)))
strictContrFibers {f = f} g b .fst = (g b , refl)
strictContrFibers {f = f} g b .snd (a , p) i = (g (p (~ i)) , λ j  f (g (p (~ i ∨ j))))

infixl 4 _>>=_
_>>=_ = R.bindTC

infixr 5 _v∷_
pattern varg t = R.arg (R.arg-info R.visible (R.modality R.relevant R.quantity-ω)) t
pattern _v∷_ a l = varg a ∷ l

strictEquivClauses : R.Term  R.Term  List R.Clause
strictEquivClauses f g =
  R.clause []
    (R.proj (quote fst) v∷ [])
    f
  ∷ R.clause []
    (R.proj (quote snd) v∷ R.proj (quote equiv-proof) v∷ [])
    (R.def (quote strictContrFibers) (g v∷ []))
  ∷ []

defStrictEquiv :  {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'}
   R.Name  (A  B)  (B  A)  R.TC Unit
defStrictEquiv idName f g =
  R.quoteTC f >>= λ `f` 
  R.quoteTC g >>= λ `g` 
  R.defineFun idName (strictEquivClauses `f` `g`)

module _ {ℓ : Level} (A : Unit  Type ℓ) where

  ΣUnit : Σ Unit A ≃ A tt
  unquoteDef ΣUnit = defStrictEquiv {-B = A tt-} ΣUnit snd λ{ x  (tt , x) }

The current master can find the solution B = A tt, but not this PR.

NB: When I change the last term from pattern-lambda λ{ x → (tt , x) } to ordinary lambda or section (tt ,_), then B is no longer solved even on master. So the pattern-lambda seems some kind of hack here to enhance the type checker, but it is a bit brittle.

@andreasabel
Copy link
Member Author

I filed agda/cubical#1143. This one change makes this PR go through with cubical.

Original introduced in PR #5006 commit 22e9a12
@andreasabel andreasabel merged commit 2d921dd into master Jul 24, 2024
27 checks passed
@andreasabel andreasabel deleted the remove-AnnP branch July 24, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reflection Elaborator reflection, macros, tactic arguments type: task Concerning the development of Agda (not in changelog)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is pattern AnnP unused? (added in Oct 2020 as "not usable yet")
2 participants