The documentation of implicit generalization mentions in its BNF that a name for a binder can be provided inside brackets:
Definition foo `({n} : nat) : nat := n.
By pure curiosity, what's the meaning/purpose of this construction ?
It is just the combination of a maximally implicit argument {n}
and of a generalizable type `(nat)
(except that there is nothing to generalize in nat
).
But n
doesn't end up as a maximally implicit argument:
Definition foo `({n} : nat) : nat := n.
About foo.
(*
foo : nat -> nat
foo is not universe polymorphic
Arguments foo _%nat_scope
foo is transparent
Expands to: Constant raro.foo
*)
That looks like a bug then.
I think coq lets you write {name} deep in a term in binder position, but it simply ignores the curly. Imo this is a shallow instance of that behavior
the useful behavior is covered by this syntax:
Definition foo `{n : nat} : nat := n.
@Enrico Tassi you mean like in Definition foo : Type := ∀ {U}, U.
? That gives a warning at least:
Ignoring implicit binder declaration in unexpected position.
[unexpected-implicit-declaration,syntax]
BTW, I'm pleasantly surprised that generalization does compose with non-maximal implicits in the right way!
Definition foo `[n : nat] (x : nat) : nat := n.
yes I was talking about that, and I was not aware of the warning...
Enrico Tassi said:
I think coq lets you write {name} deep in a term in binder position, but it simply ignores the curly. Imo this is a shallow instance of that behavior
When the name is followed by a type, Coq only accept {name : T}
and not {name} : T
or ({name} : T)
which is entirely reasonable but makes the quirk above quite awkward.
Last updated: Oct 05 2023 at 02:01 UTC