You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- | 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)
}
Our dependent pattern matching substitutes the unification not only on the rhs's expected type but also on the rhs expression. This means that the AST changes during typechecking.
Therefore, it makes a difference whether we pretty-print the checked vs. the unchecked output:
cargo run -- fmt 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, x) }
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) }
The text was updated successfully, but these errors were encountered:
Here is one idea I had about how to solve this: First, observe that substitution only changes variables. So we could change the AST node for variables to add an extra field:
structVariable{
...,/// Elaborated due to dependent. pattern matching.elaborated:Option<Exp>}
And then we define an operation elaborate which is just like substitution, but fills in this elaboration instead of replacing the variable. We could also avoid code duplication by reusing the substitution code appropriately.
Consider the following example:
Our dependent pattern matching substitutes the unification not only on the rhs's expected type but also on the rhs expression. This means that the AST changes during typechecking.
Therefore, it makes a difference whether we pretty-print the checked vs. the unchecked output:
cargo run -- fmt examples/foo.pol
cargo run -- fmt --checked examples/foo.pol
The text was updated successfully, but these errors were encountered: