Documentation

StrataDDM.Elab.Core

def StrataDDM.TypeExprF.instType {α : Type} (d : TypeExprF α) (bindings : Array (TypeExprF α)) :
Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Get the kind as a qualified identifier.

    Equations
    Instances For

      This expands type aliases appearing at the head of the term so the head is in a normal form.

      Attempt to interpret e as a n-ary function, and return the type of the arguments along with the return type if possible, or error (args, r) where args is an array with size args.size < n and r is the resulting type.

      Equations
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Instances For
            Instances For
              @[implicit_reducible]
              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.
              Instances For

                This translate a possibly qualified identifier into a declaration in an open dialect.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    Equations
                    Instances For
                      def StrataDDM.Elab.checkArgSize {α : Type u_1} [ToStrataFormat α] (loc : SourceRange) (name : α) (expected : Nat) (args : Array Tree) :
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def StrataDDM.Elab.translateTypeIdent (elabInfo : ElabInfo) (qualIdentInfo : Tree) (args : Array Tree) :

                        This resolves a type identifer using the name of the type (as name) and the arguments

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

                            This expands type aliases appearing at the head of the term so the root is in a normal for,.

                            N.B. This expects that macros have already been expanded in e.

                            This checks that two types itype and rtype are equivalent.

                            In this context, itype refers to a type inferred from an operator argument at position stx and rtype refers to a type inferred or specifed by a previous argument.

                            partial def StrataDDM.Elab.unifyTypeVectors {argc : Nat} (isTypeP : Fin argcBool) (argLevel0 : Fin argc) (ea : Array TypeExpr) (tctx : TypingContext) (exprSyntax : Lean.Syntax) (ia : Array TypeExpr) (args : Vector (Option Tree) argc) :
                            partial def StrataDDM.Elab.unifyTypes {argc : Nat} (isTypeP : Fin argcBool) (argLevel0 : Fin argc) (expectedType : TypeExpr) (tctx : TypingContext) (exprSyntax : Lean.Syntax) (inferredType : TypeExpr) (args : Vector (Option Tree) argc) :

                            This compares the inferred type against the expected type for an argument to check if the argument value is well-typed and determine if additional type variables can be automatically inferred.

                            • isTypeP returns true if the argument at the given index is a type.
                            • argLevel refers to the index of the argument in args
                            • expectedType is the type of the argument for the operation/expression. Bound variables in it may refer to args in args less than argIndex.
                            • tctx is the typing context for inferredType.
                            • exprSyntax is the syntax of the expression/operator this is for. Used for positions in error reporting.
                            • inferredType is the type inferred from bottom up type inference. Bound variables in it may refere to bound variables in tctx.
                            • args is the current arguments. These may be refined by unifyTypes and the new arguments are returned.
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def StrataDDM.Elab.collectNewBindingsM {m : Type u_1 → Type u_2} {α : Type u_1} [Monad m] (initialScope : Nat) (tree : Tree) (f : SourceRangeBindingm α) :
                                m (Array α)

                                This collects the results of applying a function f to the bindings added to the resulting context of tree after the initial number of bindings given by initialScope.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  def StrataDDM.Elab.elabArgIndex {α : Type} {n : Nat} (initialScope : Nat) (trees : Vector Tree n) (argsIndex : Option (DebruijnIndex n)) (f : SourceRangeBindingElabM α) :
                                  Equations
                                  Instances For
                                    @[irreducible]

                                    Parse TypeApp and TypeParen expressions to get Init.TypeExpr into head-format form.

                                    Equations
                                    Instances For
                                      theorem StrataDDM.Elab.Array_size1 {α : Type u_1} [SizeOf α] {as : Array α} (szp : as.size = 1) :
                                      sizeOf as = sizeOf as[0] + 3
                                      theorem StrataDDM.Elab.Array_size2 {α : Type u_1} [SizeOf α] {as : Array α} (szp : as.size = 2) :
                                      sizeOf as = sizeOf as[0] + sizeOf as[1] + 4
                                      theorem StrataDDM.Elab.Pair_size {α : Type u_1} {β : Type u_2} [SizeOf α] [SizeOf β] (a : α) (b : β) :
                                      @[irreducible]
                                      theorem StrataDDM.Elab.flattenTypeApp_size (arg : Tree) (args : Array Tree) :
                                      sizeOf (flattenTypeApp arg args) sizeOf arg + sizeOf args + 1

                                      Evaluate the tree as a type expression.

                                      @[irreducible]

                                      Evaluate the tree as a type expression.

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

                                        Evaluate the tree as a type expression.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          def StrataDDM.Elab.elabTypeParams {n : Nat} (initSize : Nat) (args : Vector Tree n) (idx : Option (DebruijnIndex n)) :

                                          Extract type parameter names from a bindings argument.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            def StrataDDM.Elab.evalBindingSpec {bindings : ArgDecls} (tctx : TypingContext) (loc : SourceRange) (initSize : Nat) (dialectName : DialectName) (b : BindingSpec bindings) (args : Vector Tree bindings.size) :

                                            Construct a binding from a binding spec and the arguments to an operation.

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

                                              Given a type expression and a natural number, this returns a

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

                                                Returns the type of e in typing context tctx.

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

                                                  Given a tree from operations with category Init.TypeExpr, build a tree with the type or category successfully translated.

                                                  def StrataDDM.Elab.getSyntaxArgs (stx : Lean.Syntax) (ident : QualifiedIdent) (expected : Nat) :

                                                  Return the arguments to the given syntax declaration.

                                                  This should alway succeeed, but captures an internal error if an invariant check fails.

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

                                                    The kind of elaboration to perform for an argument in runSyntaxElaborator. Unlike ArgDeclKind, this distinguishes pre-types (which need macro expansion) from already-resolved type expressions.

                                                    Instances For
                                                      partial def StrataDDM.Elab.elabSyntaxArg {argc : Nat} (getKind : Fin argcElabArgKind) (isTypeP : Fin argcBool) (tctx : TypingContext) (astx : Lean.Syntax) (argIdx : Fin argc) (trees : Vector (Option Tree) argc) :

                                                      Elaborate a single argument based on its ElabArgKind. Returns the updated trees vector with the result placed at argIdx.

                                                      partial def StrataDDM.Elab.runSyntaxElaborator {argc : Nat} (getKind : Fin argcElabArgKind) (se : SyntaxElaborator) (tctx0 : TypingContext) (args : Vector Lean.Syntax se.syntaxCount) :

                                                      Elaborate all syntax arguments for an operation according to the SyntaxElaborator's ordering. Iterates over se.argElaborators, computes the typing context for each argument (handling datatype scopes for recursive types), and delegates to elabSyntaxArg for the actual elaboration. Returns the elaborated Tree vector and the result TypingContext.

                                                      partial def StrataDDM.Elab.elaborateWithPreRegistrationCore {argc : Nat} (argDecls : Vector ArgDecl argc) (se : SyntaxElaborator) (tctx0 : TypingContext) (fallbackLoc : SourceRange) (stxArgs : Vector Lean.Syntax se.syntaxCount) (scopeArgLevel : Nat) (label : String) (extractInfo : GlobalContextLean.SyntaxElabM GlobalContext) :

                                                      Two-phase elaboration for operations annotated with @[preRegisterTypes] or @[preRegisterFunctions].

                                                      • Phase 1: Resolve the scope argument, extract children, and fold extractInfo over them to pre-register names in the GlobalContext.
                                                      • Phase 2: Fully elaborate all args with the updated context.

                                                      label is used in error messages to identify the caller.

                                                      For @[preRegisterTypes]: pre-registers type-level bindings so mutual type references resolve. Known deviation: typeParams args are elaborated twice — once in Phase 1 (against tctx0) to extract param names, and again in Phase 2 (against the per-child context). Phase 1 typeParams trees cannot be reused because collectNewBindingsM requires tree.info.inputCtx.bindings.size ≥ initialScope, which fails when the Phase 1 context is smaller than the Phase 2 per-child context.

                                                      For @[preRegisterFunctions]: pre-registers expression-level bindings (function signatures) so mutual calls resolve.

                                                      Phase 1 helper for a single child function in a mutual recursive block.

                                                      Partially elaborates the child's name, bindings, and return type to extract the function signature, then pre-registers it as an expression-level binding in the GlobalContext. This makes all sibling function names (including self) available when elaborating bodies in Phase 2.

                                                      Phase 1 helper for a single child operation in a mutual block.

                                                      Partially elaborates the child's name and typeParams args to extract the type name and parameter names, then pre-registers the type in the TypingContext's GlobalContext via preRegisterType. Returns the updated TypingContext with the new type registered.

                                                      def StrataDDM.Elab.runElab {α : Type} (action : ElabM α) :
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For