-
Notifications
You must be signed in to change notification settings - Fork 364
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
Agda ignores constructor parameters but only if they're copied under a parameterised module #7664
Comments
hm. |
The is that the copy of
but |
(I'm not sure how known this is, but it's a bit surprising to me that during LHS checking, the checkpoints are completely incorrect: if I complicate the reproducer slightly, and add a bunch of prints, Agda seems to be telling me that the way to substitute a term from context-telescope
Edit -- I suppose I've run into the LHS checker having weird checkpoints in the past.) |
That's what getModuleParameterSub and its ilk are for, unless I'm missing something? |
Regarding checkpoints in the LHS checker, they are indeed not correct at the moment since the LHS checker does not actually make use of checkpoints! It just computes telescopes and substitutions the manual way. Only once we go to the RHS we actually perform the modifications to the context (and thus insert the new checkpoint). The reason is simply that the LHS checker predates the checkpoint machinery, and no-one went through the trouble of rewriting it the proper way using checkpoints. |
The feature is crucial for programmers. For example, a program must not confuse of what is happening in the domain of the module OfVector(n) and in the domain of the module OfVector(suc n). In particular, I use inductive proofs on such parameter n. |
For any occasion, I copy here my bug report from Zulip. This is on Agda version 2.7.0.1 Type checking:
Below And Agda does not report of the error. module Test where
open import Data.List using (List; length)
open import Data.Nat using (ℕ; suc)
open import Relation.Binary.PropositionalEquality using (_≡_)
module OfVector {α} (A : Set α) (n : ℕ)
where
data Vector : Set α where
vec : (xs : List A) → length xs ≡ n → Vector
module Test (m : ℕ)
where
open OfVector ℕ m using (Vector; vec) -- vectors of length m
open OfVector ℕ (suc m) using () -- vectors of length 1+m
renaming (Vector to Vector'; vec to vec')
test : Vector' → ℕ
test (vec _ _) = 0 If |
Well, unfortunately getModuleParameterSub :: (MonadTCEnv m, ReadTCState m) => ModuleName -> m (Maybe Substitution)
getModuleParameterSub m = do
mcp <- (^. stModuleCheckpoints . key m) <$> getTCState
traverse checkpointSubstitution mcp So it's not helpful here. I couldn't figure out how to compute the substitution to the module context in the middle of pattern matching since AFAICT |
cc @UlfNorell — turns out this is sometimes possible! Start with a data type in a parameterised module:
Then make some copies, but get your wires crossed:
Agda rightfully complains that we've used the constructor
foo' : Foo
to match on a Foo. But now, add some vacuous quantification:This goes through!
The text was updated successfully, but these errors were encountered: