Documentation

Strata.DL.Lambda.Factory

Lambda's Factory #

This module formalizes Lambda's factory, which is a mechanism to extend the type checker (see Strata.DL.Lambda.LExprT) and partial evaluator (see Strata.DL.Lambda.LExprEval) by providing a map from operations to their types and optionally, denotations. The factory allows adding type checking and evaluation support for new operations without modifying the implementation of either or any core ASTs.

Also see Strata.DL.Lambda.IntBoolFactory for a concrete example of a factory.

@[reducible, inline]
abbrev Lambda.Signature (IDMeta Ty : Type) :

A signature is a map from variable identifiers to types.

Equations
Instances For
    @[reducible, inline]
    abbrev Lambda.LMonoTySignature {IDMeta : Type} :
    Equations
    Instances For
      @[reducible, inline]
      abbrev Lambda.LTySignature {IDMeta : Type} :
      Equations
      Instances For
        Equations
        Instances For
          Equations
          Instances For
            Equations
            Instances For
              @[reducible, inline]

              A Lambda factory function - instantiation of Func for Lambda expressions.

              Universally quantified type identifiers, if any, appear before this signature and can quantify over the type identifiers in it.

              Equations
              Instances For
                def Lambda.LFunc.mk {T : LExprParams} (name : T.Identifier) (typeArgs : List TyIdentifier := []) (isConstr : Bool := false) (inputs : ListMap T.Identifier LMonoTy) (output : LMonoTy) (body : Option (LExpr T.mono) := none) (attr : Array String := #[]) (concreteEval : Option (T.MetadataList (LExpr T.mono)Option (LExpr T.mono)) := none) (axioms : List (LExpr T.mono) := []) :

                Helper constructor for LFunc to maintain backward compatibility.

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

                          The type checker and partial evaluator for Lambda is parameterizable by a user-provided Factory.

                          We don't have any "built-in" functions like +, -, etc. in (LExpr IDMeta) -- lambdas are our only tool. Factory gives us a way to add support for concrete/symbolic evaluation and type checking for FunFactory functions without actually modifying any core logic or the ASTs.

                          Equations
                          Instances For
                            Equations
                            Instances For

                              Add a function func to the factory F. Redefinitions are not allowed.

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

                                Append a factory newF to an existing factory F, checking for redefinitions along the way.

                                Equations
                                Instances For
                                  def Lambda.getLFuncCall {T : LExprParams} {GenericTy : Type} (e : LExpr { base := T, TypeType := GenericTy }) :
                                  LExpr { base := T, TypeType := GenericTy } × List (LExpr { base := T, TypeType := GenericTy })
                                  Equations
                                  Instances For
                                    def Lambda.getLFuncCall.go {T : LExprParams} {GenericTy : Type} (e : LExpr { base := T, TypeType := GenericTy }) (acc : List (LExpr { base := T, TypeType := GenericTy })) :
                                    LExpr { base := T, TypeType := GenericTy } × List (LExpr { base := T, TypeType := GenericTy })
                                    Equations
                                    Instances For
                                      def Lambda.getConcreteLFuncCall {T : LExprParams} {GenericTy : Type} (e : LExpr { base := T, TypeType := GenericTy }) :
                                      LExpr { base := T, TypeType := GenericTy } × List (LExpr { base := T, TypeType := GenericTy })
                                      Equations
                                      Instances For
                                        def Lambda.Factory.callOfLFunc {T : LExprParams} {GenericTy : Type} (F : Factory T) (e : LExpr { base := T, TypeType := GenericTy }) (allowPartialApp : Bool := false) :
                                        Option (LExpr { base := T, TypeType := GenericTy } × List (LExpr { base := T, TypeType := GenericTy }) × LFunc T)

                                        If e is a call of a factory function, get the operator (.op), a list of all the actuals, and the (LFunc IDMeta).

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          theorem Lambda.getLFuncCall.go_size {T : LExprParamsT} {e : LExpr T} {op : LExpr { base := T.base, TypeType := T.TypeType }} {args acc : List (LExpr { base := T.base, TypeType := T.TypeType })} :
                                          go e acc = (op, args)op.sizeOf + (List.map LExpr.sizeOf args).sum e.sizeOf + (List.map LExpr.sizeOf acc).sum
                                          theorem Lambda.List.sum_size_le {α : Type u_1} (f : αNat) {l : List α} {x : α} (x_in : x l) :
                                          f x (List.map f l).sum
                                          theorem Lambda.getLFuncCall_smaller {T : LExprParamsT} {e : LExpr T} {op : LExpr { base := T.base, TypeType := T.TypeType }} {args : List (LExpr { base := T.base, TypeType := T.TypeType })} :
                                          getLFuncCall e = (op, args)∀ (a : LExpr { base := T.base, TypeType := T.TypeType }), a argsa.sizeOf < e.sizeOf
                                          theorem Lambda.Factory.callOfLFunc_smaller {T : LExprParamsT} {F : Factory T.base} {e : LExpr T} {op : LExpr { base := T.base, TypeType := T.TypeType }} {args : List (LExpr { base := T.base, TypeType := T.TypeType })} {F' : LFunc T.base} {allowPartialMatch : Bool} :
                                          F.callOfLFunc e allowPartialMatch = some (op, args, F')∀ (a : LExpr { base := T.base, TypeType := T.TypeType }), a argsa.sizeOf < e.sizeOf