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

Should n be size tel? #6096

Closed
nad opened this issue Sep 9, 2022 · 3 comments
Closed

Should n be size tel? #6096

nad opened this issue Sep 9, 2022 · 3 comments
Assignees
Labels
type: task Concerning the development of Agda (not in changelog) type-checking
Milestone

Comments

@nad
Copy link
Contributor

nad commented Sep 9, 2022

Consider what happens if the size of tel is less than n in the following code (I have verified that this can happen, see for instance test/Succeed/Issue723.agda):

-- Check the target type if we can get away with it.
chk' <- lift $
case (chk, mt1) of
(NotCheckedTarget, Just t1) | all visible args0 -> do
let n = length args0
TelV tel tgt <- telViewUpTo n t0'
let dep = any (< n) $ IntSet.toList $ freeVars tgt
vis = all visible (telToList tel)
isRigid t | PathType{} <- viewPath t = return False -- Path is not rigid!
isRigid (El _ (Pi dom _)) = return $ visible dom
isRigid (El _ (Def d _)) = getConstInfo d <&> theDef <&> \ case
Axiom{} -> True
DataOrRecSig{} -> True
AbstractDefn{} -> True
Function{funClauses = cs} -> null cs
Datatype{} -> True
Record{} -> True
Constructor{} -> __IMPOSSIBLE__
GeneralizableVar{} -> __IMPOSSIBLE__
Primitive{} -> False
PrimitiveSort{} -> False
isRigid _ = return False
rigid <- isRigid tgt
-- Andreas, 2019-03-28, issue #3248:
-- If the target type is SIZELT, we need coerce, leqType is insufficient.
-- For example, we have i : Size <= (Size< ↑ i), but not Size <= (Size< ↑ i).
isSizeLt <- reduce t1 >>= isSizeType <&> \case
Just (BoundedLt _) -> True
_ -> False
if | dep -> return chk -- must be non-dependent
| not rigid -> return chk -- with a rigid target
| not vis -> return chk -- and only visible arguments
| isSizeLt -> return chk -- Issue #3248, not Size<
| otherwise -> do
let tgt1 = applySubst (strengthenS impossible $ size tel) tgt
reportSDoc "tc.term.args.target" 30 $ vcat
[ "Checking target types first"
, nest 2 $ "inferred =" <+> prettyTCM tgt1
, nest 2 $ "expected =" <+> prettyTCM t1 ]
traceCall (CheckTargetType (fuseRange r args0) tgt1 t1) $
CheckedTarget <$> ifNoConstraints_ (compareType cmp tgt1 t1)
(return Nothing) (return . Just)
_ -> return chk

If the size of the telescope is less than n, doesn't it make sense to use size tel instead of n in dep?

@nad nad added this to the later milestone Sep 9, 2022
@UlfNorell
Copy link
Member

Yes, that looks like it should be size tel instead of n.

@nad nad self-assigned this Sep 9, 2022
@nad nad modified the milestones: later, 2.6.3 Sep 9, 2022
@nad
Copy link
Contributor Author

nad commented Sep 9, 2022

The test suite does not complain.

nad added a commit that referenced this issue Sep 9, 2022
nad added a commit that referenced this issue Sep 9, 2022
nad added a commit that referenced this issue Sep 9, 2022
nad added a commit that referenced this issue Sep 9, 2022
@nad nad closed this as completed in e3bf58d Sep 9, 2022
@andreasabel andreasabel added the type: task Concerning the development of Agda (not in changelog) label Oct 24, 2022
@andreasabel
Copy link
Member

(This issue does not have a reproducer, so we don't list it in the changelog.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task Concerning the development of Agda (not in changelog) type-checking
Projects
None yet
Development

No branches or pull requests

3 participants