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

exists (a : Type). a <: forall (a : Type). a #64

Open
gardspirito opened this issue Aug 16, 2023 · 1 comment · May be fixed by #66
Open

exists (a : Type). a <: forall (a : Type). a #64

gardspirito opened this issue Aug 16, 2023 · 1 comment · May be fixed by #66

Comments

@gardspirito
Copy link
Contributor

gardspirito commented Aug 16, 2023

I was trying to introduce impredicative instantiation for my fork of FFG. I thought that it's easy to do, given η-law is sacrificed, if I just expand <:∀R and <:∃L cases of subtype (correct me if I'm wrong). While I was doing that, I suddenly realized that subtype handles Forall and Exists in an exactly same manner.

So I built 7f63aa8 and, surprise-surprise, something is definitely off with this approach:
EDIT: There's something strange with Exists, subtype check. I tested relatively old commit 7f63aa8, and here's what I've got:

let test
    : exists (a : Type). a
	= 3
in test : forall (a : Type). a
❯ nix shell github:Gabriella439/grace/7f63aa8a1835ca1a782f18eb773c80ea2af4cd5f

❯ grace interpret test.ffg --annotate
3 : forall (a : Type) . a
@gardspirito
Copy link
Contributor Author

gardspirito commented Aug 16, 2023

Yeah, I should study the problem before I write. But I guess I found the source.

grace/src/Grace/Infer.hs

Lines 246 to 248 in cd70563

(Type.VariableType{ name = a0 }, Type.VariableType{ name = a1 })
| a0 == a1 -> do
wellFormedType _Γ _A0

Comparison is performed by name, but matching names don't necessarily mean that two variables are one and the same.
exists a. a <: forall a. a
=> forall a. (a <: forall a. a)
=> forall a. (forall a. (a <: a))

Typechecker looks at this, sees two same names and assumes that this is the same variable.
If we change the source code to:

let test
    : exists (a : Type). a
	= 3
in test : forall (a2 : Type). a2

it stops compiling, because it now sees that a ≠ a2.

EDIT: I guess that just a substitute must be made on each Variable declaration.

@gardspirito gardspirito linked a pull request Aug 18, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant