1lab/mikan
13
52
Fork
You've already forked mikan
9

Decide on a fate for non-uniform parameterised types #120

Open
opened 2026年05月27日 17:03:59 +02:00 by amyliao · 0 comments

As of #118, termination checking no longer allows proving that parameterised Acc enjoys the induction principle of indexed Acc.

Problematic call:
go y (w y y<x)
(at NonUniformTermination.agda:18.36-38)

This is a breaking change, but it's sort-of expected if we imagine writing out the induction principle for parameterised Acc:

Acc-elim:{x}(P:AccxType)((w:yy<xAccy){! ∀ y y<x → P (w y y<x) !}-- ^~~~~~~~~~~~~~~~~~~~~~~~~~~-- this is the inductive hypothesis that would justify a recursive call-- go x (acc w) → go y (w ...)-- but we can't apply P : Acc x → ... to (w y y<x) : Acc yP(accw))xAccx

However, the termination checking change only forbids uses recursion on arguments where the parameter change was caused by matching on a separate indexed-inductive type, or because that constructor argument is a dependent function returning an instance of the data type at a parameter that was introduced in the argument's own telescope. This means that a lot of non-uniformly parameterised types can still be declared and shown equivalent to their indexed versions, like this silly example:

dataParityList(A:Type)(b:Bool):Typewherenil:b≡trueParityListAb_∷_:AParityListA(notb)ParityListAbpattern[]=nilreflelim:{A:Type}(P:bParityListAbType)Ptrue[]({b}axsP(notb)xsPb(a∷xs)){b}xsPbxselimPpnilpconsxs=goxswherego:{b}xsPbxsgo[]=pnilgo(x∷xs)=pconsxxs(goxs)

So we should decide on a fate for non-uniformly recursive types. If we still want to support them, 88addd3f95 could be rolled back while still patching the incompatibility between untyped size-change termination and impredicativity by having (e.g.) the positivity checker mark the forbidden positions. If we don't want to support them, we should have the positivity checker raise error-warnings when it runs into one of the datatypes in the mutual block applied to the wrong parameters.

As of #118, termination checking no longer allows proving that *parameterised* `Acc` enjoys the induction principle of *indexed* `Acc`. https://codeberg.org/1lab/mikan/src/commit/88addd3f9572bbd2d0f426cffa244a97ab988dfc/test/Fail/NonUniformTermination.err#L3-L5 This is a breaking change, but it's sort-of expected if we imagine writing out the induction principle for *parameterised* `Acc`: ```agda Acc-elim : ∀ {x} (P : Acc x → Type) → (∀ (w : ∀ y → y < x → Acc y) → {! ∀ y y<x → P (w y y<x) !} -- ^~~~~~~~~~~~~~~~~~~~~~~~~~~ -- this is the inductive hypothesis that would justify a recursive call -- go x (acc w) → go y (w ...) -- but we can't apply P : Acc x → ... to (w y y<x) : Acc y → P (acc w)) → ∀ x → Acc x ``` However, the termination checking change only forbids uses recursion on arguments where the parameter change was caused by matching on a separate indexed-inductive type, or because that constructor argument is a dependent function returning an instance of the data type at a parameter that was introduced in the argument's own telescope. This means that a lot of non-uniformly parameterised types can still be declared and shown equivalent to their indexed versions, like this silly example: ```agda data ParityList (A : Type) (b : Bool) : Type where nil : b ≡ true → ParityList A b _∷_ : A → ParityList A (not b) → ParityList A b pattern [] = nil refl elim : ∀ {A : Type} (P : ∀ b → ParityList A b → Type) → P true [] → (∀ {b} a xs → P (not b) xs → P b (a ∷ xs)) → ∀ {b} xs → P b xs elim P pnil pcons xs = go xs where go : ∀ {b} xs → P b xs go [] = pnil go (x ∷ xs) = pcons x xs (go xs) ``` So we should decide on a fate for non-uniformly recursive types. If we still want to support them, 88addd3f9572bbd2d0f426cffa244a97ab988dfc could be rolled back while still patching the incompatibility between untyped size-change termination and impredicativity by having (e.g.) the positivity checker mark the forbidden positions. If we don't want to support them, we should have the positivity checker raise error-warnings when it runs into one of the datatypes in the mutual block applied to the wrong parameters.
Sign in to join this conversation.
No Branch/Tag specified
main
aliao/occurs-opt
aliao/rec-con
fix-license
aliao/oopsie
aliao/strengthen-iapply
No results found.
Labels
Clear labels
1 - scope
language
Backwards-compatible changes to the surface language, such as adding new features.
1 - scope
language change
Breaking changes to a documented part of the surface language. These should be documented and specifically called out in the changelog.
1 - scope
performance
Semantics-preserving performance work.
1 - scope
task
Changes that are not apparent to the user, e.g. developer documentation and refactors, which do not need to be documented.
A: dead-code
Dead code elimination and --save-metas.
A: errors
Reporting of error and warning messages.
A: highlighting
Highlighting during interaction & literate compilation
A: imports
Handling of imports and interface file de/serialization.
A: infra
Iinfrastructure (e.g. CI, developer documentation, the build system, or the repository itself)
A: instance
Instance declarations, arguments, and resolution
A: lhs
LHS checking, coverage checking, and clause compilation
A: modules
Declaration and instantiation of parametrised modules.
A: parallel
Parallel typechecking.
A: positivity
Positivity checking
A: printing
Pretty-printing, display forms, and the wording of diagnostic messages
A: records
Record declarations, record expressions and copattern matching
A: scoping
Scope checking (ConcreteToAbstract)
A: termination
Termination checking
0 - type
bug
Issues describing an incorrect behaviour in the project, typos in the documentation, etc.
0 - type
discussion
An issue raised to gather opinions on a proposed change, or a suggested language change.
0 - type
question
An issue raised to ask a question.
9 - status
duplicate
This issue or pull request already exists.
9 - status
info needed
More information is needed from the submitter to decide how to proceed with the issue report.
9 - status
invalid
The issue report or pull request does not describe an actual bug, or does otherwise does not meet the contributing guidelines.
good first issue
Interested in contributing? Get started here.
upstream
Related to an upstream repository, already reported there
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
1lab/mikan#120
Reference in a new issue
1lab/mikan
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?