Documentation

Lean.Compiler.LCNF.InferType

Type inference for LCNF #

@[inline]

We use a regular local context to store temporary local declarations created during type inference.

Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.

Create lcCast expectedType e : expectedType

Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.

Return true if type should be erased. See item 1 in the note above where x ◾ ◾ is a proposition and should be erased when the universe level parameter is set to 0.

Remark: predVars is a bitmask that indicates whether de-bruijn variables are predicates or not. That is, #i is a predicate if predVars[predVars.size - i - 1] = true

Equations

Quick check for compatibleTypes. It is not monadic, but it is incomplete because it does not eta-expand type formers. See comment at compatibleTypes.

Remark: if the result is true, then a and b are indeed compatible. If it is false, we must use the full-check.

Equations
  • One or more equations did not get rendered due to their size.

Return true if the LCNF types a and b are compatible.

Remark: a and b can be type formers (e.g., List, or fun (α : Type) => NatNat × α)

Remark: We may need to eta-expand type formers to establish whether they are compatible or not. For example, suppose we have

fun (x : B) => Id B ◾ ◾
Id B ◾

We must eta-expand Id B ◾ to fun (x : B) => Id B ◾ x. Note that, we use x instead of to make the implementation simpler and skip the check whether B is a type former type. However, this simplification should not affect correctness since is compatible with everything.

Remark: see comment at isErasedCompatible.

Remark: because of "erasure confusion" see note above, we assume (aka lcErasure) is compatible with everything. This is a simplification. We used to use isErasedCompatible, but this only address item 1. For item 2, we would have to modify the toLCNFType function and make sure a type former is erased if the expected type is not always a type former (see S.mk type and example in the note above).

Equations

Return true if the LCNF types a and b are compatible.

Remark: a and b can be type formers (e.g., List, or fun (α : Type) => NatNat × α)

Remark: We may need to eta-expand type formers to establish whether they are compatible or not. For example, suppose we have

fun (x : B) => Id B ◾ ◾
Id B ◾

We must eta-expand Id B ◾ to fun (x : B) => Id B ◾ x. Note that, we use x instead of to make the implementation simpler and skip the check whether B is a type former type. However, this simplification should not affect correctness since is compatible with everything.

Remark: see comment at isErasedCompatible.

Remark: because of "erasure confusion" see note above, we assume (aka lcErasure) is compatible with everything. This is a simplification. We used to use isErasedCompatible, but this only address item 1. For item 2, we would have to modify the toLCNFType function and make sure a type former is erased if the expected type is not always a type former (see S.mk type and example in the note above).

Equations
  • One or more equations did not get rendered due to their size.