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

Suboptimal subtyping relation? #20

Open
ecranceMERCE opened this issue Jan 18, 2024 · 1 comment
Open

Suboptimal subtyping relation? #20

ecranceMERCE opened this issue Jan 18, 2024 · 1 comment
Labels
question Further information is requested theory Theoretical aspects of the plugin

Comments

@ecranceMERCE
Copy link
Collaborator

In the definition of subtyping adopted in the article, the SubApp rule states that subtyping between $f\ x$ and $f' x'$ can only be discussed when $x = x'$. The implementation follows this definition:

trocq/elpi/annot.elpi

Lines 70 to 73 in 95f083a

% SubApp
sub-type (app [F|Xs]) (app [F'|Xs']) :-
sub-type F F',
std.forall2 Xs Xs' eq.

However, this definition seems to introduce suboptimal situations in the presence of constants.

Assume t @ list Type(α) ~ t' :. tR for a given list t containing types. Translating t @ list Type(β) by tR is therefore only authorised if list Type(α) is a subtype of list Type(β). In this case, the SubApp rule asserts that α = β, which is not necessarily true.

Indeed, we have:

tR : listR Type(α) Type(α) Param(α) t t'

which essentially means that for all values A and A' in t and t', Param(α) A A' holds. If α is higher than β, every proof Param(α) A A' can be weakened to Param(β) A A', which means the stronger witness tR at type list Type(α) should be acceptable when expecting a witness at type list Type(β). Therefore, we can state that list Type(α) is actually a subtype of list Type(β), without having α = β.

Are there concrete cases where the translation gets stuck because of this forced equality?

@ecranceMERCE ecranceMERCE added question Further information is requested theory Theoretical aspects of the plugin labels Jan 18, 2024
@CohenCyril
Copy link
Collaborator

Indeed, this is true for list essentially because we can map the weakening, i.e. list : Type(4,0) -> Type(4,0).
This is where Trocq could be used to feed its own subtyping mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested theory Theoretical aspects of the plugin
Projects
None yet
Development

No branches or pull requests

2 participants