-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I have an environment equivalence judgment that contains a rule that states that if two environments are equivalent, we can cons a binding on both and they will be equivalent:
E1 equiv E2
----------------------------- Var
E1; x : Sch equiv E2; x : Sch
The algorithm as described here will emit lc constraints "to guarantee the invariant that if a derivation holds, then the top-level terms involved are locally-closed". As we are in a System F-alike system with both term and type variables in locally nameless representation in this case this means adding a lc constraint on the typescheme Sch.
Inductive EnvEquiv : Env -> Env -> Prop := (* defn EnvEq *)
| EnvEqVar : forall (Env1:Env) (x:termvar) (Sch5:Sch) (Env2:Env),
lc_DSch Sch5 ->
EnvEq Env1 Env2 ->
EnvEq (Env_ConsVar Env1 x Sch5) (Env_ConsVar Env2 x Sch5)
The problem is that this invariant is only maintained for rules, and not for the environment itself. Therefore, environments may exist that store some open term, which means the equivalence relation now no longer is reflexive, since that would involve the case forall E1 E2 x Sch, E1 equiv E2 ==> E1; x : Sch equiv E2; x : Sch.
I would argue that the solution for this is to add a way for the lc constraints to not be generated for some rules. Two environments can be equivalent whilst storing terms that are not locally closed, as long as both store the same open term. Alternatively, this can be solved by also emitting lc constraints for the constructors of the environments, but I'm not sure that makes a lot of sense.