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

Could the termination checker be less restrictive when the K rule is turned off? #4527

Open
nad opened this issue Mar 20, 2020 · 5 comments
Open
Labels
cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp termination Issues relating to the termination checker type: enhancement Issues and pull requests about possible improvements without-K K-related restrictions to pattern matching, termination checking, indices, erasure
Milestone

Comments

@nad
Copy link
Contributor

nad commented Mar 20, 2020

The termination checker is currently more conservative when the K rule is turned off (#1023). I think that all the problematic examples that are listed in Issue #1023 rely on pattern matching on refl. If inductive families were disallowed (under some flag), would it be safe to loosen the restrictions?

@Saizan is/was working on proper support for inductive families in Cubical Agda (#3733). Is this done in such a way that the restrictions become unnecessary?

@nad nad added type: enhancement Issues and pull requests about possible improvements termination Issues relating to the termination checker without-K K-related restrictions to pattern matching, termination checking, indices, erasure cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp labels Mar 20, 2020
@andreasabel
Copy link
Member

If inductive families were disallowed (under some flag), would it be safe to loosen the restrictions?

Well, if you do not have equality in the first place, there should be no difference in K or without-K.

@nad
Copy link
Contributor Author

nad commented Mar 20, 2020

In Cubical Agda you would still have paths.

@Saizan
Copy link
Contributor

Saizan commented Mar 24, 2020

The issue with termination checking --without-K seems to be that the checker does not get to see the transports that actually happen when given a non-refl proof.

When implementing inductive families for Cubical I do generate a clause that inserts the necessary transports, so termination checking that clause should catch the examples from the other thread.

If your types are refining just because you are matching on some plain datatype then I don't think it should be rejected, as that wouldn't need extra desugaring. Someone should do a proof though?

e.g., the following is easy to translate to eliminators/see terminating, but in general?

open import Agda.Builtin.Nat

data Unit : Set where
  unit : Unit

F : Unit -> Set
F unit = Nat

test :  (x : Unit)  F x  Nat
test unit zero = zero
test unit (suc n) = suc (test unit n)

@nad
Copy link
Contributor Author

nad commented Mar 24, 2020

When implementing inductive families for Cubical I do generate a clause that inserts the necessary transports, so termination checking that clause should catch the examples from the other thread.

The idea is that --without-K should be compatible both with --with-K and with --cubical. Would it make sense to generate these clauses whenever the K rule is turned off, or could this create problems for code that relies on K? (It might make sense for compiler backends to remove the extra clauses.) In that case we could perhaps remove the restriction and rely only on regular termination checking.

@Saizan
Copy link
Contributor

Saizan commented Nov 10, 2020

A way to make the termination checker less restrictive without involving (#3733) would be to only do the masking from the solution to #1023 when there's a match on an inductive family in one of the clauses.

dsheets added a commit to dsheets/agda that referenced this issue Nov 3, 2022
… --safe

`--without-K` is supposed to be compatible with cubical but agda#1023
demonstrated an issue where cubical-compatible postulates could be used to
evade termination analysis through type substitution introducing
constructors. Here, we enable the Original Flavour termination analysis
available when `--without-K` isn't enabled when both `--without-K` and
`--safe` are enabled thus avoiding the 'cubical-compatible postulate'
problem by simply outlawing postulates.
dsheets added a commit to dsheets/agda that referenced this issue Nov 3, 2022
In particular, describe `--without-K` restriction and `--safe`
behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp termination Issues relating to the termination checker type: enhancement Issues and pull requests about possible improvements without-K K-related restrictions to pattern matching, termination checking, indices, erasure
Projects
None yet
Development

No branches or pull requests

4 participants