You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The type of a data constructor should *not* have repeated indices unless defined within the scope of with-K #2519
See the discussion on #2504 for a specific instance.
This raises the issue to library level, given the ambient stdlib assumption of cubical-compatible/without-K.
data constructors which exploit repeated occurrences/'non-linearity' are making implicit appeal to reflexivity of (propositional) equality, and that should instead be required as an explicit witness. Specialising the constructor to supply refl as a default witness should be the preferred approach to offering a non-linear constructor. Cf. Data.Nat.Divisibility.Core#2013
I agree this is a good principle going forward. However, how many definitions fall foul of this currently? Depending on the numbers I would be weary of how big a breaking change this would be to change all the existing definitions?
I haven't done a survey of the relevant definitions, besides Data.Nat.Base._≤′_, which seems to fall even more easily to the corresponding refactoring as #2504 . See commit jamesmckinna@895cd32 on branch jamesmckinna/issue2519 which is ready-to-go as a PR if you think it's worthwhile.
More generally, I'd advocate piecemeal refactoring in the interests of avoiding 'large' breaking changes?
My gut feel is that this isn't likely to occur very often. But this is rather hard to search for! So piecemeal refactoring is indeed a rather reasonable way to go.
Can you clarify what exactly you mean by "non-linear" here? Is it that the same variable should not appear in two different indices of a data constructor?
Can you clarify what exactly you mean by "non-linear" here? Is it that the same variable should not appear in two different indices of a data constructor?
Yes, exactly. I'll change the title of the issue.
In the originating PR #2504 it's actually even stronger than that, because it meant that those indices could even become parameters to the data definition.
changed the title [-]`data` constructors should *not* be non-linear unless defined within the scope of `with-K`[/-][+]The type of a `data` constructor should *not* have repeated indices unless defined within the scope of `with-K`[/+]on Dec 19, 2024
I'm not convinced by this one, given that we can prove K specialised to Bool, and this isn't some example of a wider pattern - or is it? No, this definition now looks a lot like Relation.Binary.Construct.StrictToNonStrict!
Thanks @shhyou for the endorsement, and also to @Taneb for the pushback.
Regarding the latter, for sure we can prove K for Bool, but such proof/knowledge is after-the-fact (and would need to be in Data.Bool.Properties) relative to the definition here, which for Reasons, we put such 'basic' relations in Data.X.Base...
The observation that it might now be an instance of a construction is... all to the good, as far as a subsequent refactoring would be concerned, and indeed as far as I am (!), because the strict relations (here, and in Data.Nat.Base) are, for me, indeed conceptually prior to the non-strict.
UPDATED possibly also further fuel for @JacquesCarette 's desire to move such things into... smaller submodules under Data.X?
In the meantime, you were too quick! I've just pushed #3152 ... followup discussions there for the Bool instance?
{-# OPTIONS --without-K #-}module_whereopen importData.Bool.Baseopen importRelation.Binary.PropositionalEqualityar :∀ b c → b ≤ c → c ≤ b → b ≡ c
ar b c b≤b c≤b ={!c≤b!}{-Agda version 2.10.0-be0acfe:bo.agda:9.18-19: error: [SplitError.UnificationStuck]I'm not sure if there should be a case for the constructor b≤b,because I get stuck when trying to solve the following unificationproblems (inferred index ≟ expected index): b₁ ≟ b₂ b₁ ≟ b₂Possible reason why unification failed: Cannot eliminate reflexive equation b₁ = b₁ of type Bool because K has been disabled.when checking that the expression ? has type b ≡ b-}
(Matching b and c instead of b≤c and c≤b solves the problem, of course.)
Apologies @shhyou I misread your last comment. Is this a v2.10 problem, or do we have inductive-family-related warnings turned off in stdlib which avoid this problem? I'm puzzled now... as the code I did offer typechecks under v2.9.0. Any idea what's happened/happening?
I just support changing b≤b to ≤-reflexive eq because the former definition does not allow the natural pattern-matching proofs without K (although in the specific case above matching on c≤b is redundant).
Activity
MatthewDaggitt commentedon Dec 16, 2024
I agree this is a good principle going forward. However, how many definitions fall foul of this currently? Depending on the numbers I would be weary of how big a breaking change this would be to change all the existing definitions?
jamesmckinna commentedon Dec 16, 2024
I haven't done a survey of the relevant definitions, besides
Data.Nat.Base._≤′_, which seems to fall even more easily to the corresponding refactoring as #2504 . See commit jamesmckinna@895cd32 on branchjamesmckinna/issue2519which is ready-to-go as a PR if you think it's worthwhile.More generally, I'd advocate piecemeal refactoring in the interests of avoiding 'large' breaking changes?
refactor in line with agda#2504 / agda#2519
JacquesCarette commentedon Dec 17, 2024
I agree with the design principle.
My gut feel is that this isn't likely to occur very often. But this is rather hard to search for! So piecemeal refactoring is indeed a rather reasonable way to go.
Taneb commentedon Dec 19, 2024
Can you clarify what exactly you mean by "non-linear" here? Is it that the same variable should not appear in two different indices of a data constructor?
jamesmckinna commentedon Dec 19, 2024
Yes, exactly. I'll change the title of the issue.
In the originating PR #2504 it's actually even stronger than that, because it meant that those indices could even become parameters to the
datadefinition.[-]`data` constructors should *not* be non-linear unless defined within the scope of `with-K`[/-][+]The type of a `data` constructor should *not* have repeated indices unless defined within the scope of `with-K`[/+][ refactor ] Change definition of `Data.Nat.Base._≤′_` (#2523)
jamesmckinna commentedon Aug 1, 2026
Looping back to #1344 ... where @MatthewDaggitt had the same idea, but with different motivations, in this comment.
jamesmckinna commentedon Nov 19, 2026
Another example (but yes: they are quite hard to identify...): in
Data.Bool.Basewhich should (probably; at least on the model of this proposal...) become
Taneb commentedon Nov 19, 2026
I'm not convinced by this one, given that we can prove K specialised to
Bool, and this isn't some example of a wider pattern - or is it? No, this definition now looks a lot likeRelation.Binary.Construct.StrictToNonStrict!jamesmckinna commentedon Nov 19, 2026
Thanks @shhyou for the endorsement, and also to @Taneb for the pushback.
Regarding the latter, for sure we can prove K for
Bool, but such proof/knowledge is after-the-fact (and would need to be inData.Bool.Properties) relative to the definition here, which for Reasons, we put such 'basic' relations inData.X.Base...The observation that it might now be an instance of a construction is... all to the good, as far as a subsequent refactoring would be concerned, and indeed as far as I am (!), because the strict relations (here, and in
Data.Nat.Base) are, for me, indeed conceptually prior to the non-strict.UPDATED possibly also further fuel for @JacquesCarette 's desire to move such things into... smaller submodules under
Data.X?In the meantime, you were too quick! I've just pushed #3152 ... followup discussions there for the
Boolinstance?shhyou commentedon Nov 19, 2026
But then,
(Matching
bandcinstead ofb≤candc≤bsolves the problem, of course.)jamesmckinna commentedon Nov 19, 2026
But... without having to match on the implicits, and matching on the first relational argument:
And, indeed, if we took @Taneb 's suggestion, then
≤-antisymfollows from general considerations of<-transand<-irrefl.UPDATED: see branch https://github.com/jamesmckinna/agda-stdlib/tree/bool-issue2519-bis which is based on this PR for emerging development, not yet ready even as a DRAFT PR.
jamesmckinna commentedon Nov 20, 2026
Apologies @shhyou I misread your last comment. Is this a v2.10 problem, or do we have inductive-family-related warnings turned off in
stdlibwhich avoid this problem? I'm puzzled now... as the code I did offer typechecks under v2.9.0. Any idea what's happened/happening?shhyou commentedon Nov 23, 2026
I just support changing
b≤bto≤-reflexive eqbecause the former definition does not allow the natural pattern-matching proofs without K (although in the specific case above matching onc≤bis redundant).jamesmckinna commentedon Nov 27, 2026
See also, In the wider context of this issue, the discussion in #1344 about
Closure.Reflexive...