lambdapi icon indicating copy to clipboard operation
lambdapi copied to clipboard

Renaming bound variables equal to a symbol name

Open gabrielhdt opened this issue 4 years ago • 5 comments

The example

symbol Set: TYPE
set declared "η"
injective symbol η: Set ⇒ TYPE

symbol arr: Set ⇒ Set ⇒ Set
rule η (arr &X &Y) → (η &X) ⇒ (η &Y)
set infix right 6 "~>" ≔ arr

constant symbol t: Set ⇒ TYPE
constant symbol quote {T: Set}: η T ⇒ t T

constant symbol T: Set
symbol f: η (T ~> T)
compute λ(T: Set), quote {T ~> T} (λx:η T, x) // Succeeds
compute λ(T: Set), quote {T ~> T} (λx:η T, f x)
// Fails with [T] and [T] are not convertible.

Fails with the error message

[T] and [T] are not convertible

Is it solved by #328?

gabrielhdt avatar Apr 09 '20 06:04 gabrielhdt

No

fblanqui avatar Apr 09 '20 06:04 fblanqui

My mistake, there is no problem, I have a constant named T as well as a variable, so the type of f is η T ⇒ η T (where T is the constant), but the type of x is η T, where T is the variable.

Should we provide something to distinguish, or should the user be careful?

gabrielhdt avatar Apr 09 '20 07:04 gabrielhdt

Right. But we could perhaps do something about this by providing some warning or by making sure that names used for printing bound variables are distinct from locally declared function symbols. @rlepigre @craff couldn't https://github.com/rlepigre/ocaml-bindlib/ provide such a feature? I remember some previous version of Bindlib had a function to exclude some identifiers.

fblanqui avatar Apr 09 '20 07:04 fblanqui

Yeah, that is possible but currently Lambdapi is not set up of that. There is the Bindlib.*_in family of functions that can be used for that. However, I feel like that this is rather a user problem here. I would be kind of weird to rename variables that appear in the file.

One solution would be to introduce a syntactic distinction between symbols and variables, but I'm not sure how I feel about that.

rlepigre avatar Apr 09 '20 09:04 rlepigre

In the current syntax:

symbol Set: TYPE;
injective symbol η: Set → TYPE;
symbol arr: Set → Set → Set;
rule η (arr $X $Y) ↪ (η $X) → (η $Y);
constant symbol t: Set → TYPE;
constant symbol quote [T: Set]: η T → t T;
constant symbol T: Set;
symbol f: η (arr T T);
compute λ(T: Set), quote [arr T T] (λ x:η T, x);
compute λ(T: Set), quote [arr T T] (λ x:η T, f x);

fblanqui avatar Mar 01 '24 10:03 fblanqui