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

Unguarded Fixpoint becomes guarded after section closes #14317

Closed
anton-trunov opened this issue May 13, 2021 · 10 comments · Fixed by #14395
Closed

Unguarded Fixpoint becomes guarded after section closes #14317

anton-trunov opened this issue May 13, 2021 · 10 comments · Fixed by #14395
Labels
kind: inconsistency Proof of False accepted by the kernel and/or checker. part: sections The section mechanism of Coq. priority: blocker The next release should be delayed if this is not fixed.
Milestone

Comments

@anton-trunov
Copy link
Member

Description of the problem

Consider the following snippet:

Section FooSect.

Unset Guard Checking.

Fixpoint loop (n : nat) : nat := loop n.
Print Assumptions loop.
(*
Axioms:
loop is assumed to be guarded.
*)
End FooSect.

Print Assumptions loop.
(* Closed under the global context *)

I would expect the last Print Assumptions to say "loop is assumed to be guarded".

Coq Version

8.13.2 and somewhat recent master (b78e6cf).

@anton-trunov anton-trunov added the part: sections The section mechanism of Coq. label May 13, 2021
@ejgallego ejgallego added kind: inconsistency Proof of False accepted by the kernel and/or checker. priority: blocker The next release should be delayed if this is not fixed. labels May 13, 2021
@ejgallego
Copy link
Member

There is a trivial proof of False using this, so raising priority.

@SkySkimmer
Copy link
Contributor

The easiest fix would be to forbid changing consistency flags inside sections.

@ejgallego
Copy link
Member

How come the typing flags were not preserved during elaboration at section closing time?

@ejgallego
Copy link
Member

The easiest fix would be to forbid changing consistency flags inside sections.

That would still feel a bit fragile maybe?

@SkySkimmer
Copy link
Contributor

We could also stop losing the typing flags in

let cb = Term_typing.translate_recipe senv.env kn r in

However there is also a hole if you do something like

Section S.
  Unset Guard Checking.
  Let bad := fix bad (n:nat) : False := bad n.
  Set Guard Checking.
  Definition really_bad := bad 0.
End S.
Print Assumptions really_bad.

since section variables don't have attached typing flags.

@ppedrot
Copy link
Member

ppedrot commented May 14, 2021

IMHO the only sound way to store guardedness is to put it in the (co)Fix node. Otherwise we still have issues with reduction functions.

@ejgallego
Copy link
Member

IMHO the only sound way to store guardedness is to put it in the (co)Fix node. Otherwise we still have issues with reduction functions.

What about other flags? This doesn't save you from having to traverse everything anyways.

I was thinking of this problem more in the line of "environment tainting", once an environment is tainted, it is not easy to have it back. Morally the sections should preserve tainting [as would typing rules if you add a tainted bit to \Gamma], so the above example once elaborated should be equivalent to:

Unset Guard Checking.
Fixpoint foo := ...
Set Guard Checking.
Definition a := foo ...
Print Assumptions a.

@ppedrot
Copy link
Member

ppedrot commented May 14, 2021

This doesn't save you from having to traverse everything

Yes, but Print Assumption does that anyways.

What about other flags?

It depends. Some of them would benefit from having an explicit representation in the term, notably type-in-type (with a dedicated sort). I belive that impredicative set should also be done that way. Positivity checking is better handled in the inductive block since they can't be unfolded. For the other ones it's a bit murky.

@Zimmi48 Zimmi48 added this to the 8.14+rc1 milestone May 22, 2021
@Zimmi48
Copy link
Member

Zimmi48 commented May 22, 2021

Did everybody forget about this issue? I'm putting it in the 8.14+rc1 milestone (because otherwise the blocker label amounts to nothing). But IMHO this would deserve an 8.13.3 release (cc @gares).

@gares
Copy link
Member

gares commented May 23, 2021

Thanks for the heads up.

SkySkimmer added a commit to SkySkimmer/coq that referenced this issue May 26, 2021
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue May 26, 2021
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue May 26, 2021
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: inconsistency Proof of False accepted by the kernel and/or checker. part: sections The section mechanism of Coq. priority: blocker The next release should be delayed if this is not fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants