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

Feature request: don't convert a forall to an implicitation if it has an explicit variable name #14912

Open
cpitclaudel opened this issue Sep 21, 2021 · 6 comments
Labels
kind: wish Feature or enhancement requests. part: printer The printing mechanism of Coq.

Comments

@cpitclaudel
Copy link
Contributor

I commonly run into the following two related issues:

  1. If a quantified variable doesn't appear in the goal, its name is lost:

    Inductive Strs := Const (s: string) | Sub (s: Strs) (start len: nat) | Concat (s1 s2: Strs).
    
    Goal forall s: Strs, True.
      Fail destruct s. (* This should succeed, and the goal should be `forall s, True`, not `Strs -> True`. *)
      destruct 1.
  2. When printing an inductive, the name of its arguments are often lost:

    Print Strs.
    
    Inductive Strs : Set :=
        Const : string -> Strs
      | Sub : Strs -> nat -> nat -> Strs
      | Concat : Strs -> Strs -> Strs

Would it be possible to preserve explicitly named binders? I imagine this might break things, so it would have to be under a flag? Fixing the output of Print, on the other hand, should be safe?

Coq Version

8.13

@ppedrot
Copy link
Member

ppedrot commented Sep 21, 2021

The name is technically still there in the AST, it's just ignored by notation printing. Meanwhile, destruct is explicitly designed to ignore the internal name and rely on the user-facing display, similarly to what #13837 tries to solve.

@Alizter Alizter added kind: bug An error, flaw, fault or unintended behaviour. part: printer The printing mechanism of Coq. kind: wish Feature or enhancement requests. and removed kind: bug An error, flaw, fault or unintended behaviour. labels Sep 29, 2021
@Alizter
Copy link
Contributor

Alizter commented Sep 29, 2021

Is this really something well-defined? To me, destruct s for forall s, P s would be a bit silly since the goal is alpha equivalent to any other renaming of s. In this case destruct 1 is the more sensible syntax no?

For the second, even if you have printing of low level contents, it appears that the names have been lost (replaced with _). I guess this is something that needs to be addressed.

@ppedrot
Copy link
Member

ppedrot commented Sep 29, 2021

destruct 1 does not mean the same thing, it's quite precisely the opposite. If you pass an integer to destruct it will use the first non-dependent premise. So in particular, it would not be printed as a forall.

it appears that the names have been lost

It's quite easy to fix, but then you'd have nasty interactions with tactics relying on user-facing printing.

@cpitclaudel
Copy link
Contributor Author

Is this really something well-defined?

I think so?

To me, destruct s for forall s, P s would be a bit silly since the goal is alpha equivalent to any other renaming of s.

destruct 1 doesn't work on forall s, P s, nor should it, AFAIK:

Axiom P: nat -> Prop.
Goal forall s, P s.
  destruct 1.
  (* Error: No 1st non dependent hypothesis in current goal even after head-reduction. *)

Am I misunderstanding you?

@Alizter
Copy link
Contributor

Alizter commented Sep 29, 2021

I misunderstood the meaning of destruct 1 as pointed out by ppedrot above. My first point is that s doesn't really exist as a variable in the environment so it seemed a bit dubious for a tactic to mention it.

@cpitclaudel
Copy link
Contributor Author

It's quite easy to fix, but then you'd have nasty interactions with tactics relying on user-facing printing.

Things like intros *, or is it something more pervasive? (I was guessing it would affect handwritten scripts but not so much automated ones.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: wish Feature or enhancement requests. part: printer The printing mechanism of Coq.
Projects
None yet
Development

No branches or pull requests

3 participants