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

Never substitute unification variables for variables #346

Open
timsueberkrueb opened this issue Nov 6, 2024 · 1 comment
Open

Never substitute unification variables for variables #346

timsueberkrueb opened this issue Nov 6, 2024 · 1 comment
Labels
bug Something isn't working unification

Comments

@timsueberkrueb
Copy link
Collaborator

Consider the following example:

-- | The Martin-Löf equality type.
data Eq(implicit a: Type, x y: a) {
    -- | The reflexivity constructor.
    Refl(implicit a: Type, x: a): Eq(a:=a, x, x)
}

-- | Proof of symmetry of equality.
def Eq(x, y).sym(implicit a: Type, x y: a): Eq(a:=a, y, x) {
    Refl(a, x) => Refl(a:=a, x)
}

When printing the checked AST, we observe:

cargo run -- fmt --checked examples/foo.pol

-- | The Martin-Löf equality type.
data Eq(implicit a: Type, x y: a) {
    -- | The reflexivity constructor.
    Refl(implicit a: Type, x: a): Eq(a:=a, x, x)
}

-- | Proof of symmetry of equality.
def Eq(x, y).sym(implicit a: Type, x y: a): Eq(a:=a, y, x) { Refl(a, x) => Refl(a:=<a>, y) }

Here, a:=a was substituted to a:=<a> where <a> is a hole corresponding to the inserted metavariable ?0 from the scrutinee type Eq(?0, x, y).

@timsueberkrueb timsueberkrueb added the bug Something isn't working label Nov 6, 2024
@BinderDavid
Copy link
Collaborator

The problem is that when we compute a unifying substitution for use in dependent pattern matching then unsolved metavariables shouldn't occur in the RHS of the substitution.
Otherwise we might have accidental information flowing from inside a clause to the outside. (Cp. the problems described in the OutsideIn paper)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unification
Projects
None yet
Development

No branches or pull requests

2 participants