Documentation

MeTTaIL.Semantics.WellSorted

@[reducible, inline]

A typing context: the sort of each free variable.

Equations
Instances For

    The argument categories of a function symbol, read off its rule's non-terminal items in order.

    Equations
    Instances For
      inductive MeTTaIL.WellSorted (p : Presentation) (Γ : Ctx) :
      ASTCatProp

      WellSorted p Γ t c: term t has sort c in context Γ, with every subterm well-sorted. A variable has its context sort; an application has its function symbol's result sort, with arguments well-sorted at the symbol's argument sorts.

      Instances For
        inductive MeTTaIL.WellSortedList (p : Presentation) (Γ : Ctx) :
        List ASTList CatProp

        Pointwise well-sortedness of an argument list against a list of categories.

        Instances For
          theorem MeTTaIL.inst_wellSorted {p : Presentation} {Γ Δ : Ctx} {bnds : List (String × AST)} (hb : ∀ (x : String) (c : Cat), List.lookup x Δ = some cWellSorted p Γ (AST.inst bnds (AST.var (DottedPath.base x))) c) {t : AST} {c : Cat} :
          WellSorted p Δ t cWellSorted p Γ (AST.inst bnds t) c

          The substitution lemma (inst half): instantiating a well-sorted term with a substitution that is well-sorted for the source context yields a well-sorted term. Proved by mutual induction on the well-sortedness derivation: a variable is handled by the substitution hypothesis, an application recurses into its arguments.

          theorem MeTTaIL.instList_wellSorted {p : Presentation} {Γ Δ : Ctx} {bnds : List (String × AST)} (hb : ∀ (x : String) (c : Cat), List.lookup x Δ = some cWellSorted p Γ (AST.inst bnds (AST.var (DottedPath.base x))) c) {ts : List AST} {cs : List Cat} :
          WellSortedList p Δ ts csWellSortedList p Γ (AST.instList bnds ts) cs