Documentation

Lean.Expr

inductive Lean.Literal :

Literal values for Expr.

Instances For
    @[implicit_reducible]
    @[implicit_reducible]
    @[implicit_reducible]
    Instances For
      @[implicit_reducible]

      Total order on Expr literal values. Natural number values are smaller than string literal values.

      Instances For
        @[implicit_reducible]
        @[implicit_reducible]

        Arguments in forallE binders can be labelled as implicit or explicit.

        Each lam or forallE binder comes with a binderInfo argument (stored in ExprData). This can be set to

        • default -- (x : α)
        • implicit -- {x : α}
        • strict_implicit -- ⦃x : α⦄
        • inst_implicit -- [x : α].
        • aux_decl -- Auxiliary definitions are helper methods that Lean generates. aux_decl is used for _match, _fun_match, _let_match and the self reference that appears in recursive pattern matching.

        The difference between implicit {} and strict-implicit ⦃⦄ is how implicit arguments are treated that are not followed by explicit arguments. {} arguments are applied eagerly, while ⦃⦄ arguments are left partially applied:

        def foo {x : Nat} : Nat := x
        def bar ⦃x : Nat⦄ : Nat := x
        #check foo -- foo : Nat
        #check bar -- bar : ⦃x : Nat⦄ → Nat
        

        See also the Lean Language Reference.

        • default : BinderInfo

          Default binder annotation, e.g. (x : α)

        • implicit : BinderInfo

          Implicit binder annotation, e.g., {x : α}

        • strictImplicit : BinderInfo

          Strict implicit binder annotation, e.g., {{ x : α }}

        • instImplicit : BinderInfo

          Local instance binder annotation, e.g., [Decidable α]

        Instances For
          @[implicit_reducible]
          @[implicit_reducible]

          Return true if the given BinderInfo does not correspond to an implicit binder annotation (i.e., implicit, strictImplicit, or instImplicit).

          Instances For
            @[implicit_reducible]

            Return true if the given BinderInfo is an instance implicit annotation (e.g., [Decidable α])

            Instances For

              Return true if the given BinderInfo is a regular implicit annotation (e.g., {α : Type u})

              Instances For

                Return true if the given BinderInfo is a strict implicit annotation (e.g., {{α : Type u}})

                Instances For
                  @[reducible, inline]

                  Expression metadata. Used with the Expr.mdata constructor.

                  Instances For
                    @[reducible, inline]
                    Instances For

                      Cached hash code, cached results, and other data for Expr.

                      • hash : 32-bits
                      • approxDepth : 8-bits -- the approximate depth is used to minimize the number of hash collisions
                      • hasFVar : 1-bit -- does it contain free variables?
                      • hasExprMVar : 1-bit -- does it contain metavariables?
                      • hasLevelMVar : 1-bit -- does it contain level metavariables?
                      • hasLevelParam : 1-bit -- does it contain level parameters?
                      • looseBVarRange : 20-bits

                      Remark: this is mostly an internal datastructure used to implement Expr, most will never have to use it.

                      Instances For
                        @[implicit_reducible]
                        Instances For
                          @[implicit_reducible]
                          Instances For
                            @[extern lean_uint8_to_uint64]
                            Instances For
                              @[extern lean_expr_mk_data]
                              opaque Lean.Expr.mkData (h : UInt64) (looseBVarRange : Nat := 0) (approxDepth : UInt32 := 0) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool := false) :
                              @[extern lean_expr_mk_app_data]
                              opaque Lean.Expr.mkAppData (fData aData : Data) :

                              Optimized version of Expr.mkData for applications.

                              @[inline]
                              def Lean.Expr.mkDataForBinder (h : UInt64) (looseBVarRange : Nat) (approxDepth : UInt32) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool) :
                              Instances For
                                @[inline]
                                def Lean.Expr.mkDataForLet (h : UInt64) (looseBVarRange : Nat) (approxDepth : UInt32) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool) :
                                Instances For
                                  @[implicit_reducible]
                                  structure Lean.FVarId :

                                  The unique free variable identifier. It is just a hierarchical name, but we wrap it in FVarId to make sure they don't get mixed up with MVarId.

                                  This is not the user-facing name for a free variable. This information is stored in the local context (LocalContext). The unique identifiers are generated using a NameGenerator.

                                  Instances For
                                    @[implicit_reducible]
                                    @[implicit_reducible]
                                    @[implicit_reducible]
                                    @[implicit_reducible]

                                    A set of unique free variable identifiers. This is a persistent data structure implemented using Std.TreeSet.

                                    Instances For
                                      @[implicit_reducible]
                                      @[implicit_reducible]
                                      Instances For
                                        Instances For

                                          A set of unique free variable identifiers implemented using hashtables. Hashtables are faster than red-black trees if they are used linearly. They are not persistent data-structures.

                                          Instances For

                                            A mapping from free variable identifiers to values of type α. This is a persistent data structure implemented using Std.TreeMap.

                                            Instances For
                                              def Lean.FVarIdMap.insert {α : Type} (s : FVarIdMap α) (fvarId : FVarId) (a : α) :
                                              Instances For
                                                @[implicit_reducible]
                                                @[implicit_reducible]
                                                structure Lean.MVarId :

                                                Universe metavariable Id

                                                Instances For
                                                  @[implicit_reducible]
                                                  @[implicit_reducible]
                                                  @[implicit_reducible]
                                                  @[implicit_reducible]
                                                  Instances For
                                                    @[implicit_reducible]
                                                    Instances For
                                                      @[implicit_reducible]
                                                      Instances For
                                                        def Lean.MVarIdMap.insert {α : Type} (s : MVarIdMap α) (mvarId : MVarId) (a : α) :
                                                        Instances For
                                                          @[implicit_reducible]
                                                          @[implicit_reducible]
                                                          instance Lean.instForInMVarIdMapProdMVarIdOfMonad {m : Type u_1 → Type u_2} {α : Type} [Monad m] :
                                                          ForIn m (MVarIdMap α) (MVarId × α)
                                                          @[implicit_reducible]
                                                          @[extern lean_expr_data]
                                                          noncomputable def Lean.Expr.data :
                                                          Instances For
                                                            inductive Lean.Expr :

                                                            Lean expressions. This data structure is used in the kernel and elaborator. However, expressions sent to the kernel should not contain metavariables.

                                                            Remark: we use the E suffix (short for Expr) to avoid collision with keywords. We considered using «...», but it is too inconvenient to use.

                                                            • bvar (deBruijnIndex : Nat) : Expr

                                                              The bvar constructor represents bound variables, i.e. occurrences of a variable in the expression where there is a variable binder above it (i.e. introduced by a lam, forallE, or letE).

                                                              The deBruijnIndex parameter is the de-Bruijn index for the bound variable. See the Wikipedia page on de-Bruijn indices for additional information.

                                                              For example, consider the expression fun x : Nat => forall y : Nat, x = y. The x and y variables in the equality expression are constructed using bvar and bound to the binders introduced by the earlier lam and forallE constructors. Here is the corresponding Expr representation for the same expression:

                                                              .lam `x (.const `Nat [])
                                                                (.forallE `y (.const `Nat [])
                                                                  (.app (.app (.app (.const `Eq [.succ .zero]) (.const `Nat [])) (.bvar 1)) (.bvar 0))
                                                                  .default)
                                                                .default
                                                              
                                                            • fvar (fvarId : FVarId) : Expr

                                                              The fvar constructor represent free variables. These free variable occurrences are not bound by an earlier lam, forallE, or letE constructor and its binder exists in a local context only.

                                                              Note that Lean uses the locally nameless approach. See McBride and McKinna for additional details.

                                                              When "visiting" the body of a binding expression (i.e. lam, forallE, or letE), bound variables are converted into free variables using a unique identifier, and their user-facing name, type, value (for LetE), and binder annotation are stored in the LocalContext.

                                                            • mvar (mvarId : MVarId) : Expr

                                                              Metavariables are used to represent "holes" in expressions, and goals in the tactic framework. Metavariable declarations are stored in the MetavarContext. Metavariables are used during elaboration, and are not allowed in the kernel, or in the code generator.

                                                            • sort (u : Level) : Expr

                                                              Used for Type u, Sort u, and Prop:

                                                              • Prop is represented as .sort .zero,
                                                              • Sort u as .sort (.param `u), and
                                                              • Type u as .sort (.succ (.param `u))
                                                            • const (declName : Name) (us : List Level) : Expr

                                                              A (universe polymorphic) constant that has been defined earlier in the module or by another imported module. For example, @Eq.{1} is represented as Expr.const `Eq [.succ .zero], and @Array.map.{0, 0} is represented as Expr.const `Array.map [.zero, .zero].

                                                            • app (fn arg : Expr) : Expr

                                                              A function application.

                                                              For example, the natural number one, i.e. Nat.succ Nat.zero is represented as Expr.app (.const `Nat.succ []) (.const .zero []). Note that multiple arguments are represented using partial application.

                                                              For example, the two argument application f x y is represented as Expr.app (.app f x) y.

                                                            • lam (binderName : Name) (binderType body : Expr) (binderInfo : BinderInfo) : Expr

                                                              A lambda abstraction (aka anonymous functions). It introduces a new binder for variable x in scope for the lambda body.

                                                              For example, the expression fun x : Nat => x is represented as

                                                              Expr.lam `x (.const `Nat []) (.bvar 0) .default
                                                              
                                                            • forallE (binderName : Name) (binderType body : Expr) (binderInfo : BinderInfo) : Expr

                                                              A dependent arrow (a : α) → β) (aka forall-expression) where β may dependent on a. Note that this constructor is also used to represent non-dependent arrows where β does not depend on a.

                                                              For example:

                                                            • letE (declName : Name) (type value body : Expr) (nondep : Bool) : Expr

                                                              Let-expressions.

                                                              The let-expression let x : Nat := 2; Nat.succ x is represented as

                                                              Expr.letE `x (.const `Nat []) (.lit (.natVal 2)) (.app (.const `Nat.succ []) (.bvar 0)) true
                                                              

                                                              If the nondep flag is true, then the elaborator treats this as a non-dependent let (known as a have expression). Given an environment, a metavariable context, and a local context, we say a let-expression let x : t := v; e is non-dependent when it is equivalent to (fun x : t => e) v. In contrast, the dependent let-expression let n : Nat := 2; fun (a : Array Nat n) (b : Array Nat 2) => a = b is type correct, but (fun (n : Nat) (a : Array Nat n) (b : Array Nat 2) => a = b) 2 is not.

                                                              The kernel does not verify nondep when type checking. This is an elaborator feature.

                                                            • lit : LiteralExpr

                                                              Natural number and string literal values.

                                                              They are not really needed, but provide a more compact representation in memory for these two kinds of literals, and are used to implement efficient reduction in the elaborator and kernel. The "raw" natural number 2 can be represented as Expr.lit (.natVal 2). Note that, it is definitionally equal to:

                                                              Expr.app (.const `Nat.succ []) (.app (.const `Nat.succ []) (.const `Nat.zero []))
                                                              
                                                            • mdata (data : MData) (expr : Expr) : Expr

                                                              Metadata (aka annotations).

                                                              We use annotations to provide hints to the pretty-printer, store references to Syntax nodes, position information, and save information for elaboration procedures (e.g., we use the inaccessible annotation during elaboration to mark Exprs that correspond to inaccessible patterns).

                                                              Note that Expr.mdata data e is definitionally equal to e.

                                                            • proj (typeName : Name) (idx : Nat) (struct : Expr) : Expr

                                                              Projection-expressions. They are redundant, but are used to create more compact terms, speedup reduction, and implement eta for structures. The type of struct must be an structure-like inductive type. That is, it has only one constructor, is not recursive, and it is not an inductive predicate. The kernel and elaborators check whether the typeName matches the type of struct, and whether the (zero-based) index is valid (i.e., it is smaller than the number of constructor fields). When exporting Lean developments to other systems, proj can be replaced with typeName.rec applications.

                                                              Example, given a : Nat × Bool, a.1 is represented as

                                                              .proj `Prod 0 a
                                                              
                                                            Instances For
                                                              @[implicit_reducible]
                                                              Instances For
                                                                @[implicit_reducible]

                                                                The constructor name for the given expression. This is used for debugging purposes.

                                                                Instances For
                                                                  Instances For
                                                                    @[implicit_reducible]

                                                                    Return true if e contains free variables. This is a constant time operation.

                                                                    Instances For

                                                                      Return true if e contains expression metavariables. This is a constant time operation.

                                                                      Instances For

                                                                        Return true if e contains universe (aka Level) metavariables. This is a constant time operation.

                                                                        Instances For

                                                                          Does the expression contain level (aka universe) or expression metavariables? This is a constant time operation.

                                                                          Instances For

                                                                            Return true if e contains universe level parameters. This is a constant time operation.

                                                                            Instances For

                                                                              Return the approximated depth of an expression. This information is used to compute the expression hash code, and speedup comparisons. This is a constant time operation. We say it is approximate because it maxes out at 255.

                                                                              Instances For

                                                                                The range of de-Bruijn variables that are loose. That is, bvars that are not bound by a binder. For example, bvar i has range i + 1 and an expression with no loose bvars has range 0.

                                                                                Instances For

                                                                                  Return the binder information if e is a lambda or forall expression, and .default otherwise.

                                                                                  Instances For

                                                                                    Export functions.

                                                                                    @[export lean_expr_hash]
                                                                                    Instances For
                                                                                      @[export lean_expr_has_fvar]
                                                                                      Instances For
                                                                                        @[export lean_expr_has_expr_mvar]
                                                                                        Instances For
                                                                                          @[export lean_expr_has_level_mvar]
                                                                                          Instances For
                                                                                            @[export lean_expr_has_mvar]
                                                                                            Instances For
                                                                                              @[export lean_expr_has_level_param]
                                                                                              Instances For
                                                                                                @[export lean_expr_loose_bvar_range]
                                                                                                Instances For
                                                                                                  @[export lean_expr_binder_info]
                                                                                                  Instances For
                                                                                                    def Lean.mkConst (declName : Name) (us : List Level := []) :

                                                                                                    mkConst declName us return .const declName us.

                                                                                                    Instances For

                                                                                                      Return the type of a literal value.

                                                                                                      Instances For
                                                                                                        @[export lean_lit_type]
                                                                                                        Instances For
                                                                                                          def Lean.mkBVar (idx : Nat) :

                                                                                                          .bvar idx is now the preferred form.

                                                                                                          Instances For

                                                                                                            .sort u is now the preferred form.

                                                                                                            Instances For
                                                                                                              def Lean.mkFVar (fvarId : FVarId) :

                                                                                                              .fvar fvarId is now the preferred form. This function is seldom used, free variables are often automatically created using the telescope functions (e.g., forallTelescope and lambdaTelescope) at MetaM.

                                                                                                              Instances For
                                                                                                                def Lean.mkMVar (mvarId : MVarId) :

                                                                                                                .mvar mvarId is now the preferred form. This function is seldom used, metavariables are often created using functions such as mkFreshExprMVar at MetaM.

                                                                                                                Instances For
                                                                                                                  def Lean.mkMData (m : MData) (e : Expr) :

                                                                                                                  .mdata m e is now the preferred form.

                                                                                                                  Instances For
                                                                                                                    def Lean.mkProj (structName : Name) (idx : Nat) (struct : Expr) :

                                                                                                                    .proj structName idx struct is now the preferred form.

                                                                                                                    Instances For
                                                                                                                      @[match_pattern]
                                                                                                                      def Lean.mkApp (f a : Expr) :

                                                                                                                      .app f a is now the preferred form.

                                                                                                                      Instances For
                                                                                                                        def Lean.mkLambda (x : Name) (bi : BinderInfo) (t b : Expr) :

                                                                                                                        .lam x t b bi is now the preferred form.

                                                                                                                        Instances For
                                                                                                                          def Lean.mkForall (x : Name) (bi : BinderInfo) (t b : Expr) :

                                                                                                                          .forallE x t b bi is now the preferred form.

                                                                                                                          Instances For

                                                                                                                            Return Unit -> type. Do not confuse with Thunk type

                                                                                                                            Instances For

                                                                                                                              Return fun (_ : Unit), e

                                                                                                                              Instances For
                                                                                                                                @[inline]
                                                                                                                                def Lean.mkLet (x : Name) (t v b : Expr) (nondep : Bool := false) :

                                                                                                                                Returns let x : t := v; b, a let expression. If nondep := true, then returns a have.

                                                                                                                                Instances For
                                                                                                                                  @[inline]
                                                                                                                                  def Lean.mkHave (x : Name) (t v b : Expr) :

                                                                                                                                  Returns have x : t := v; b, a non-dependent let expression.

                                                                                                                                  Instances For
                                                                                                                                    @[match_pattern]
                                                                                                                                    def Lean.mkAppB (f a b : Expr) :
                                                                                                                                    Instances For
                                                                                                                                      @[match_pattern]
                                                                                                                                      def Lean.mkApp2 (f a b : Expr) :
                                                                                                                                      Instances For
                                                                                                                                        @[match_pattern]
                                                                                                                                        def Lean.mkApp3 (f a b c : Expr) :
                                                                                                                                        Instances For
                                                                                                                                          @[match_pattern]
                                                                                                                                          def Lean.mkApp4 (f a b c d : Expr) :
                                                                                                                                          Instances For
                                                                                                                                            @[match_pattern]
                                                                                                                                            def Lean.mkApp5 (f a b c d e : Expr) :
                                                                                                                                            Instances For
                                                                                                                                              @[match_pattern]
                                                                                                                                              def Lean.mkApp6 (f a b c d e₁ e₂ : Expr) :
                                                                                                                                              Instances For
                                                                                                                                                @[match_pattern]
                                                                                                                                                def Lean.mkApp7 (f a b c d e₁ e₂ e₃ : Expr) :
                                                                                                                                                Instances For
                                                                                                                                                  @[match_pattern]
                                                                                                                                                  def Lean.mkApp8 (f a b c d e₁ e₂ e₃ e₄ : Expr) :
                                                                                                                                                  Instances For
                                                                                                                                                    @[match_pattern]
                                                                                                                                                    def Lean.mkApp9 (f a b c d e₁ e₂ e₃ e₄ e₅ : Expr) :
                                                                                                                                                    Instances For
                                                                                                                                                      @[match_pattern]
                                                                                                                                                      def Lean.mkApp10 (f a b c d e₁ e₂ e₃ e₄ e₅ e₆ : Expr) :
                                                                                                                                                      Instances For
                                                                                                                                                        @[match_pattern]

                                                                                                                                                        .lit l is now the preferred form.

                                                                                                                                                        Instances For
                                                                                                                                                          @[match_pattern]

                                                                                                                                                          Returns the "raw" natural number .lit (.natVal n). This is not the default representation used by the Lean frontend. See mkNatLit.

                                                                                                                                                          Instances For

                                                                                                                                                            Returns instOfNatNat n : OfNat Nat n

                                                                                                                                                            Instances For
                                                                                                                                                              Instances For
                                                                                                                                                                @[match_pattern]

                                                                                                                                                                Returns a natural number literal used in the frontend. It is a OfNat.ofNat application. Recall that all theorems and definitions containing numeric literals are encoded using OfNat.ofNat applications in the frontend.

                                                                                                                                                                Instances For
                                                                                                                                                                  @[match_pattern]

                                                                                                                                                                  Return the string literal .lit (.strVal s)

                                                                                                                                                                  Instances For
                                                                                                                                                                    @[export lean_expr_mk_bvar]
                                                                                                                                                                    Instances For
                                                                                                                                                                      @[export lean_expr_mk_fvar]
                                                                                                                                                                      Instances For
                                                                                                                                                                        @[export lean_expr_mk_mvar]
                                                                                                                                                                        Instances For
                                                                                                                                                                          @[export lean_expr_mk_sort]
                                                                                                                                                                          Instances For
                                                                                                                                                                            @[export lean_expr_mk_const]
                                                                                                                                                                            def Lean.mkConstEx (c : Name) (lvls : List Level) :
                                                                                                                                                                            Instances For
                                                                                                                                                                              @[export lean_expr_mk_app]
                                                                                                                                                                              def Lean.mkAppEx :
                                                                                                                                                                              ExprExprExpr
                                                                                                                                                                              Instances For
                                                                                                                                                                                @[export lean_expr_mk_lambda]
                                                                                                                                                                                def Lean.mkLambdaEx (n : Name) (d b : Expr) (bi : BinderInfo) :
                                                                                                                                                                                Instances For
                                                                                                                                                                                  @[export lean_expr_mk_forall]
                                                                                                                                                                                  def Lean.mkForallEx (n : Name) (d b : Expr) (bi : BinderInfo) :
                                                                                                                                                                                  Instances For
                                                                                                                                                                                    @[export lean_expr_mk_let]
                                                                                                                                                                                    def Lean.mkLetEx (n : Name) (t v b : Expr) (nondep : Bool) :
                                                                                                                                                                                    Instances For
                                                                                                                                                                                      @[export lean_expr_mk_lit]
                                                                                                                                                                                      Instances For
                                                                                                                                                                                        @[export lean_expr_mk_mdata]
                                                                                                                                                                                        Instances For
                                                                                                                                                                                          @[export lean_expr_mk_proj]
                                                                                                                                                                                          def Lean.mkProjEx :
                                                                                                                                                                                          NameNatExprExpr
                                                                                                                                                                                          Instances For
                                                                                                                                                                                            def Lean.mkAppN (f : Expr) (args : Array Expr) :

                                                                                                                                                                                            mkAppN f #[a₀, ..., aₙ] constructs the application f a₀ a₁ ... aₙ.

                                                                                                                                                                                            Instances For
                                                                                                                                                                                              def Lean.mkAppRange (f : Expr) (i j : Nat) (args : Array Expr) :

                                                                                                                                                                                              mkAppRange f i j #[a_1, ..., a_i, ..., a_j, ... ] ==> the expression f a_i ... a_{j-1}

                                                                                                                                                                                              Instances For
                                                                                                                                                                                                def Lean.mkAppRev (fn : Expr) (revArgs : Array Expr) :

                                                                                                                                                                                                Same as mkApp f args but reversing args.

                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  @[extern lean_expr_dbg_to_string]
                                                                                                                                                                                                  @[extern lean_expr_quick_lt]
                                                                                                                                                                                                  opaque Lean.Expr.quickLt (a b : Expr) :

                                                                                                                                                                                                  A total order for expressions. We say it is quick because it first compares the hashcodes.

                                                                                                                                                                                                  @[extern lean_expr_lt]
                                                                                                                                                                                                  opaque Lean.Expr.lt (a b : Expr) :

                                                                                                                                                                                                  A total order for expressions that takes the structure into account (e.g., variable names).

                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    @[extern lean_expr_eqv]
                                                                                                                                                                                                    opaque Lean.Expr.eqv (a b : Expr) :

                                                                                                                                                                                                    Return true iff a and b are alpha equivalent. Binder annotations are ignored.

                                                                                                                                                                                                    @[implicit_reducible]
                                                                                                                                                                                                    @[extern lean_expr_equal]
                                                                                                                                                                                                    opaque Lean.Expr.equal (a b : Expr) :

                                                                                                                                                                                                    Return true iff a and b are equal. Binder names and annotations are taken into account.

                                                                                                                                                                                                    Return true if the given expression is a .sort ..

                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                      Return true if the given expression is of the form .sort (.succ ..).

                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                        Return true if the given expression is of the form .sort (.succ .zero).

                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                          Return true if the given expression is .sort .zero

                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                            Return true if the given expression is a bound variable.

                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                              Return true if the given expression is a metavariable.

                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                Return true if the given expression is a free variable.

                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                  Return true if the given expression is an application.

                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                    Return true if the given expression is a projection .proj ..

                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                      Return true if the given expression is a constant.

                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                        Return true if the given expression is a constant of the given name. Examples:

                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                          Return true if the given expression is a free variable with the given id. Examples:

                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                            Return true if the given expression is a forall-expression aka (dependent) arrow.

                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                              Return true if the given expression is a lambda abstraction aka anonymous function.

                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                Return true if the given expression is a forall or lambda expression.

                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                  Return true if the given expression is a let-expression or a have-expression.

                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                    Return true if the given expression is a non-dependent let-expression (a have-expression).

                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      @[export lean_expr_is_have]
                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                        Return true if the given expression is a metadata.

                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                          Return true if the given expression is a literal value.

                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                    def Lean.Expr.appArg (e : Expr) (h : e.isApp = true) :
                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                      def Lean.Expr.appFn (e : Expr) (h : e.isApp = true) :
                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                  If the expression is a constant, return that name. Otherwise panic.

                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                    If the expression is a constant, return that name. Otherwise return Option.none.

                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                      If the expression is a constant, return that name. Otherwise return Name.anonymous.

                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                          Return the "body" of a forall expression. Example: let e be the representation for forall (p : Prop) (q : Prop), p ∧ q, then getForallBody e returns .app (.app (.const `And []) (.bvar 1)) (.bvar 0)

                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                              Given a sequence of nested foralls (a₁ : α₁) → ... → (aₙ : αₙ) → _, returns the names [a₁, ... aₙ].

                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                Returns the number of leading binders of an expression. Ignores metadata.

                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                  If the given expression is a sequence of function applications f a₁ .. aₙ, return f. Otherwise return the input expression.

                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                    Similar to getAppFn, but skips mdata

                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                      def Lean.Expr.isAppOf (e : Expr) (n : Name) :

                                                                                                                                                                                                                                                                                                                      Given f a₀ a₁ ... aₙ, returns true if f is a constant with name n.

                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                        Given f a₁ ... aᵢ, returns true if f is a constant with name n and has the correct number of arguments.

                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                          Similar to isAppOfArity but skips Expr.mdata.

                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                            Counts the number n of arguments for an expression f a₁ .. aₙ.

                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                              Like getAppNumArgs but ignores metadata.

                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                def Lean.Expr.getBoundedAppFn (maxArgs : Nat) :

                                                                                                                                                                                                                                                                                                                                Like Lean.Expr.getAppFn but assumes the application has up to maxArgs arguments. If there are any more arguments than this, then they are returned by getAppFn as part of the function.

                                                                                                                                                                                                                                                                                                                                In particular, if the given expression is a sequence of function applications f a₁ .. aₙ, returns f a₁ .. aₖ where k is minimal such that n - k ≤ maxArgs.

                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  @[inline]

                                                                                                                                                                                                                                                                                                                                  Given f a₁ a₂ ... aₙ, returns #[a₁, ..., aₙ]

                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                    @[inline]

                                                                                                                                                                                                                                                                                                                                    Like Lean.Expr.getAppArgs but returns up to maxArgs arguments.

                                                                                                                                                                                                                                                                                                                                    In particular, given f a₁ a₂ ... aₙ, returns #[aₖ₊₁, ..., aₙ] where k is minimal such that the size of this array is at most maxArgs.

                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                      @[inline]

                                                                                                                                                                                                                                                                                                                                      Same as getAppArgs but reverse the output array.

                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                        @[specialize #[]]
                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.withAppAux {α : Sort u_1} (k : ExprArray Exprα) :
                                                                                                                                                                                                                                                                                                                                        ExprArray ExprNatα
                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.withApp {α : Sort u_1} (e : Expr) (k : ExprArray Exprα) :
                                                                                                                                                                                                                                                                                                                                          α

                                                                                                                                                                                                                                                                                                                                          Given e = f a₁ a₂ ... aₙ, returns k f #[a₁, ..., aₙ].

                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                            Return the function (name) and arguments of an application.

                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                              @[inline]

                                                                                                                                                                                                                                                                                                                                              Given f a_1 ... a_n, returns #[a_1, ..., a_n]. Note that f may be an application. The resulting array has size n even if f.getAppNumArgs < n.

                                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                                Given e of the form f a_1 ... a_n, return f. If n is greater than the number of arguments, then return e.getAppFn.

                                                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                                                  Given e of the form f a_1 ... a_n ... a_m, return f a_1 ... a_n. If n is greater than the arity, then return e.

                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                    def Lean.Expr.traverseApp {M : TypeType u_1} [Monad M] (f : ExprM Expr) (e : Expr) :

                                                                                                                                                                                                                                                                                                                                                    Given e = fn a₁ ... aₙ, runs f on fn and each of the arguments aᵢ and makes a new function application with the results.

                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                                                                                      def Lean.Expr.withAppRev {α : Sort u_1} (e : Expr) (k : ExprArray Exprα) :
                                                                                                                                                                                                                                                                                                                                                      α

                                                                                                                                                                                                                                                                                                                                                      Same as withApp but with arguments reversed.

                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                            Similar to getRevArg! but skips mdata

                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                                                                                              def Lean.Expr.getArg! (e : Expr) (i : Nat) (n : Nat := e.getAppNumArgs) :

                                                                                                                                                                                                                                                                                                                                                              Given f a₀ a₁ ... aₙ, returns the ith argument or panics if out of bounds.

                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                                                                                                                                                                def Lean.Expr.getArg!' (e : Expr) (i : Nat) (n : Nat := e.getAppNumArgs') :

                                                                                                                                                                                                                                                                                                                                                                Similar to getArg!, but skips mdata

                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                                                                                  def Lean.Expr.getArgD (e : Expr) (i : Nat) (v₀ : Expr) (n : Nat := e.getAppNumArgs) :

                                                                                                                                                                                                                                                                                                                                                                  Given f a₀ a₁ ... aₙ, returns the ith argument or returns v₀ if out of bounds.

                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                    Return true if e contains any loose bound variables.

                                                                                                                                                                                                                                                                                                                                                                    This is a constant time operation.

                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                      Return true if e is a non-dependent arrow. Remark: the following function assumes e does not have loose bound variables.

                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                        @[extern lean_expr_has_loose_bvar]
                                                                                                                                                                                                                                                                                                                                                                        opaque Lean.Expr.hasLooseBVar (e : Expr) (bvarIdx : Nat) :

                                                                                                                                                                                                                                                                                                                                                                        Return true if e contains the specified loose bound variable with index bvarIdx.

                                                                                                                                                                                                                                                                                                                                                                        This operation traverses the expression tree.

                                                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.hasLooseBVarInExplicitDomain (e : Expr) (bvarIdx : Nat) (considerRange : Bool) :

                                                                                                                                                                                                                                                                                                                                                                        Returns true if e contains the loose bound variable bvarIdx in an explicit parameter, or in the range if considerRange == true. Additionally, if the bound variable appears in an implicit parameter, it transitively looks for that implicit parameter.

                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                          @[extern lean_expr_lower_loose_bvars]
                                                                                                                                                                                                                                                                                                                                                                          opaque Lean.Expr.lowerLooseBVars (e : Expr) (s d : Nat) :

                                                                                                                                                                                                                                                                                                                                                                          Lower the loose bound variables >= s in e by d. That is, a loose bound variable bvar i with i >= s is mapped to bvar (i-d).

                                                                                                                                                                                                                                                                                                                                                                          Remark: if s < d, then the result is e.

                                                                                                                                                                                                                                                                                                                                                                          @[extern lean_expr_lift_loose_bvars]
                                                                                                                                                                                                                                                                                                                                                                          opaque Lean.Expr.liftLooseBVars (e : Expr) (s d : Nat) :

                                                                                                                                                                                                                                                                                                                                                                          Lift loose bound variables >= s in e by d.

                                                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.inferImplicit (e : Expr) (numParams : Nat) (considerRange : Bool) :

                                                                                                                                                                                                                                                                                                                                                                          inferImplicit e numParams considerRange updates the first numParams parameter binder annotations of the e forall type. It marks any parameter with an explicit binder annotation if there is another explicit arguments that depends on it or the resulting type if considerRange == true.

                                                                                                                                                                                                                                                                                                                                                                          Remark: we use this function to infer the binder annotations of structure projections.

                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                            Uses binderInfos? to update the binder infos of the corresponding forall expressions.

                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                              def Lean.Expr.updateBinderNames (e : Expr) (binderNames? : List (Option Name)) :

                                                                                                                                                                                                                                                                                                                                                                              Uses binderNames? to update the binder names of the corresponding lambda and forall expressions.

                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_instantiate]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.instantiate (e : Expr) (subst : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Instantiates the loose bound variables in e using the subst array, where a loose Expr.bvar i at "binding depth" d is instantiated with subst[i - d] if 0 <= i - d < subst.size, and otherwise it is replaced with Expr.bvar (i - subst.size); non-loose bound variables are not touched.

                                                                                                                                                                                                                                                                                                                                                                                If we imagine all expressions as being able to refer to the infinite list of loose bound variables ..., 3, 2, 1, 0 in that order, then conceptually instantiate is instantiating the last n of these and reindexing the remaining ones. Warning: instantiate uses the de Bruijn indexing to index the subst array, which might be the reverse order from what you might expect. See also Lean.Expr.instantiateRev.

                                                                                                                                                                                                                                                                                                                                                                                Terminology. The "binding depth" of a subexpression is the number of bound variables available to that subexpression by virtue of being in the bodies of Expr.forallE, Expr.lam, and Expr.letE expressions. A bound variable Expr.bvar i is "loose" if its de Bruijn index i is not less than its binding depth.)

                                                                                                                                                                                                                                                                                                                                                                                About instantiation. Instantiation isn't mere substitution. When an expression from subst is being instantiated, its internal loose bound variables have their de Bruijn indices incremented by the binding depth of the replaced loose bound variable. This is necessary for the substituted expression to still refer to the correct binders after instantiation. Similarly, the reason loose bound variables not instantiated using subst have their de Bruijn indices decremented like Expr.bvar (i - subst.size) is that instantiate can be used to eliminate binding expressions internal to a larger expression, and this adjustment keeps these bound variables referring to the same binders.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_instantiate1]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.instantiate1 (e subst : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Instantiates loose bound variable 0 in e using the expression subst, where in particular a loose Expr.bvar i at binding depth d is instantiated with subst if i = d, and otherwise it is replaced with Expr.bvar (i - 1); non-loose bound variables are not touched.

                                                                                                                                                                                                                                                                                                                                                                                If we imagine all expressions as being able to refer to the infinite list of loose bound variables ..., 3, 2, 1, 0 in that order, then conceptually instantiate1 is instantiating the last one of these and reindexing the remaining ones.

                                                                                                                                                                                                                                                                                                                                                                                This function is equivalent to instantiate e #[subst], but it avoids allocating an array.

                                                                                                                                                                                                                                                                                                                                                                                See the documentation for Lean.Expr.instantiate for a description of instantiation. In short, during instantiation the loose bound variables in subst have their own de Bruijn indices updated to account for the binding depth of the replaced loose bound variable.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_instantiate_rev]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.instantiateRev (e : Expr) (subst : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Instantiates the loose bound variables in e using the subst array. This is equivalent to Lean.Expr.instantiate e subst.reverse, but it avoids reversing the array. In particular, rather than instantiating Expr.bvar i with subst[i - d] it instantiates with subst[subst.size - 1 - (i - d)], where d is the binding depth.

                                                                                                                                                                                                                                                                                                                                                                                This function instantiates with the "forwards" indexing scheme. For example, if e represents the expression fun x y => x + y, then instantiateRev e.bindingBody!.bindingBody! #[a, b] yields a + b. The instantiate function on the other hand would yield b + a, since de Bruijn indices count outwards.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_instantiate_range]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.instantiateRange (e : Expr) (beginIdx endIdx : Nat) (subst : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Similar to Lean.Expr.instantiate, but considers only the substitutions subst in the range [beginIdx, endIdx). Function panics if beginIdx <= endIdx <= subst.size does not hold.

                                                                                                                                                                                                                                                                                                                                                                                This function is equivalent to instantiate e (subst.extract beginIdx endIdx), but it does not allocate a new array.

                                                                                                                                                                                                                                                                                                                                                                                This instantiates with the "backwards" indexing scheme. See also Lean.Expr.instantiateRevRange, which instantiates with the "forwards" indexing scheme.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_instantiate_rev_range]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.instantiateRevRange (e : Expr) (beginIdx endIdx : Nat) (subst : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Similar to Lean.Expr.instantiateRev, but considers only the substitutions subst in the range [beginIdx, endIdx). Function panics if beginIdx <= endIdx <= subst.size does not hold.

                                                                                                                                                                                                                                                                                                                                                                                This function is equivalent to instantiateRev e (subst.extract beginIdx endIdx), but it does not allocate a new array.

                                                                                                                                                                                                                                                                                                                                                                                This instantiates with the "forwards" indexing scheme (see the docstring for Lean.Expr.instantiateRev for an example). See also Lean.Expr.instantiateRange, which instantiates with the "backwards" indexing scheme.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_abstract]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.abstract (e : Expr) (xs : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Replace free (or meta) variables xs with loose bound variables, with xs ordered from outermost to innermost de Bruijn index.

                                                                                                                                                                                                                                                                                                                                                                                For example, e := f x y with xs := #[x, y] goes to f #1 #0, whereas e := f x y with xs := #[y, x] goes to f #0 #1.

                                                                                                                                                                                                                                                                                                                                                                                Careful, this function does not instantiate assigned meta variables.

                                                                                                                                                                                                                                                                                                                                                                                @[extern lean_expr_abstract_range]
                                                                                                                                                                                                                                                                                                                                                                                opaque Lean.Expr.abstractRange (e : Expr) (n : Nat) (xs : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Similar to abstract, but consider only the first min n xs.size entries in xs.

                                                                                                                                                                                                                                                                                                                                                                                def Lean.Expr.replaceFVar (e fvar v : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                Replace occurrences of the free variable fvar in e with v

                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                  def Lean.Expr.replaceFVarId (e : Expr) (fvarId : FVarId) (v : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                  Replace occurrences of the free variable fvarId in e with v

                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                    def Lean.Expr.replaceFVars (e : Expr) (fvars vs : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                    Replace occurrences of the free variables fvars in e with vs

                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                                                                                                                                                                                      Returns true when the expression does not have any sub-expressions.

                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                        def Lean.mkDecIsTrue (pred proof : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                          def Lean.mkDecIsFalse (pred proof : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                            @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                            abbrev Lean.ExprMap (α : Type) :
                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                              @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                abbrev Lean.SExprMap (α : Type) :
                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                  @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                    @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                      @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                                                                                                        Auxiliary type for forcing == to be structural equality for Expr

                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                          @[implicit_reducible]
                                                                                                                                                                                                                                                                                                                                                                                                          @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                            @[reducible, inline]
                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.Expr.mkAppRevRange (f : Expr) (beginIdx endIdx : Nat) (revArgs : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                              mkAppRevRange f b e args == mkAppRev f (revArgs.extract b e)

                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.Expr.betaRev (f : Expr) (revArgs : Array Expr) (useZeta preserveMData : Bool := false) :

                                                                                                                                                                                                                                                                                                                                                                                                                If f is a lambda expression, than "beta-reduce" it using revArgs. This function is often used with getAppRev or withAppRev. Examples:

                                                                                                                                                                                                                                                                                                                                                                                                                • betaRev (fun x y => t x y) #[] ==> fun x y => t x y
                                                                                                                                                                                                                                                                                                                                                                                                                • betaRev (fun x y => t x y) #[a] ==> fun y => t a y
                                                                                                                                                                                                                                                                                                                                                                                                                • betaRev (fun x y => t x y) #[a, b] ==> t b a
                                                                                                                                                                                                                                                                                                                                                                                                                • betaRev (fun x y => t x y) #[a, b, c, d] ==> t d c b a Suppose t is (fun x y => t x y) a b c d, then args := t.getAppRev is #[d, c, b, a], and betaRev (fun x y => t x y) #[d, c, b, a] is t a b c d.

                                                                                                                                                                                                                                                                                                                                                                                                                If useZeta is true, the function also performs zeta-reduction (reduction of let binders) to create further opportunities for beta reduction.

                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.Expr.beta (f : Expr) (args : Array Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                  Apply the given arguments to f, beta-reducing if f is a lambda expression. See docstring for betaRev for examples.

                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                    Count the number of lambdas at the head of the given expression.

                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                      Return true if the given expression is the function of an expression that is target for (head) beta reduction. If useZeta = true, then let-expressions are visited. That is, it assumes that zeta-reduction (aka let-expansion) is going to be used.

                                                                                                                                                                                                                                                                                                                                                                                                                      See isHeadBetaTarget.

                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                        (fun x => e) a ==> e[x/a].

                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.isHeadBetaTarget (e : Expr) (useZeta : Bool := false) :

                                                                                                                                                                                                                                                                                                                                                                                                                          Return true if the given expression is a target for (head) beta reduction. If useZeta = true, then let-expressions are visited. That is, it assumes that zeta-reduction (aka let-expansion) is going to be used.

                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                            If e is of the form (fun x₁ ... xₙ => f x₁ ... xₙ) and f does not contain x₁, ..., xₙ, then return some f. Otherwise, return none.

                                                                                                                                                                                                                                                                                                                                                                                                                            It assumes e does not have loose bound variables.

                                                                                                                                                                                                                                                                                                                                                                                                                            Remark: may be 0

                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                              Similar to etaExpanded?, but only succeeds if ₙ ≥ 1.

                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                Return some e' if e is of the form optParam _ e'

                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                  Return some e' if e is of the form autoParam _ e'

                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                    @[export lean_is_out_param]

                                                                                                                                                                                                                                                                                                                                                                                                                                    Return true if e is of the form outParam _

                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                      Return true if e is of the form semiOutParam _

                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                        Return true if e is of the form optParam _ _

                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                          Return true if e is of the form autoParam _ _

                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                            Returns true if e is an application of one of the type annotation gadgets. This does not check that the application has the correct arity.

                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                              @[export lean_expr_consume_type_annotations]

                                                                                                                                                                                                                                                                                                                                                                                                                                              Remove outParam, optParam, and autoParam applications/annotations from e. Note that it does not remove nested annotations. Examples:

                                                                                                                                                                                                                                                                                                                                                                                                                                              Remove metadata annotations and outParam, optParam, and autoParam applications/annotations from e. Note that it does not remove nested annotations. Examples:

                                                                                                                                                                                                                                                                                                                                                                                                                                              Similar to appFn, but also applies cleanupAnnotations to resulting function. This function is used compile the match_expr term.

                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                    getForallArity type returns the arity of a forall-type. This function consumes nested annotations, and performs pending beta reductions. It does not use whnf. Examples:

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Checks if an expression is a "natural number numeral in normal form", i.e. of type Nat, and explicitly of the form OfNat.ofNat n where n matches .lit (.natVal n) for some literal natural number n. and if so returns n.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                      Checks if an expression is an "integer numeral in normal form", i.e. of type Nat or Int, and either a natural number numeral in normal form (as specified by nat?), or the negation of a positive natural number numeral in normal form, and if so returns the integer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                        Return true iff e contains a free variable which satisfies p.

                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.containsFVar (e : Expr) (fvarId : FVarId) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Return true if e contains the given free variable.

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                            The update functions try to avoid allocating new values using pointer equality. Note that if the update*! functions are used under a match-expression, the compiler will eliminate the double-match.

                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateApp!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.Expr.updateApp! (e newFn newArg : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.Expr.updateFVar! (e : Expr) (fvarIdNew : FVarId) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateConst!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.Expr.updateConst! (e : Expr) (newLevels : List Level) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateSort!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.Expr.updateSort! (e : Expr) (newLevel : Level) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateMData!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def Lean.Expr.updateMData! (e newExpr : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateProj!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      def Lean.Expr.updateProj! (e newExpr : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateForall!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.updateForall! (e : Expr) (newBinfo : BinderInfo) (newDomain newBody : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          @[inline]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.updateForallE! (e newDomain newBody : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateLambda!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.Expr.updateLambda! (e : Expr) (newBinfo : BinderInfo) (newDomain newBody : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.Expr.updateLambdaE! (e newDomain newBody : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[implemented_by _private.Lean.Expr.0.Lean.Expr.updateLet!Impl]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.Expr.updateLet! (e newType newVal newBody : Expr) (newNondep : Bool) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.Expr.updateLetE! (e newType newVal newBody : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Like Expr.updateLet! but preserves the nondep flag.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Eta reduction. If e is of the form (fun x => f x), then return f.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.setOption {α : Type} (e : Expr) (optionName : Name) [KVMap.Value α] (val : α) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Annotate e with the given option. The information is stored using metadata around e.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Annotate e with pp.explicit := flag The delaborator uses pp options.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Annotate e with pp.universes := flag The delaborator uses pp options.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Annotate e with pp.piBinderTypes := flag The delaborator uses pp options.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Annotate e with pp.funBinderTypes := flag The delaborator uses pp options.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Annotate e with pp.numericTypes := flag The delaborator uses pp options.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    If e is an application f a_1 ... a_n annotate f, a_1 ... a_n with pp.explicit := false, and annotate e with pp.explicit := true.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Similar for setAppPPExplicit, but only annotate children with pp.explicit := false if e does not contain metavariables.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[specialize #[]]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.traverseChildren {M : TypeType u_1} [Applicative M] (f : ExprM Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ExprM Expr

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Maps f on each immediate child of the given expression.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.Expr.foldlM {α : Type} {m : TypeType u_1} [Monad m] (f : αExprm α) (init : α) (e : Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          m α

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          e.foldlM f a folds the monadic function f over the subterms of the expression e, with initial value a.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Returns the size of e as a tree, i.e. nodes reachable via multiple paths are counted multiple times.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            This is a naive implementation that visits shared subterms multiple times instead of caching their sizes. It is primarily meant for debugging.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.mkAnnotation (kind : Name) (e : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Annotate e with the given annotation name kind. It uses metadata to store the annotation.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.annotation? (kind : Name) (e : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Return some e' if e = mkAnnotation kind e'

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Auxiliary annotation used to mark terms marked with the "inaccessible" annotation .(t) and _ in patterns.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Return some e' if e = mkInaccessible e'.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      During elaboration expressions corresponding to pattern matching terms are annotated with Syntax objects. This function returns some (stx, p') if p is the pattern p' annotated with stx

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Annotate the pattern p with stx. This is an auxiliary annotation for producing better hover information.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Return some p if e is an annotated pattern (inaccessible? or patternWithRef?)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Annotate e with the LHS annotation. The delaborator displays expressions of the form lhs = rhs as lhs when they have this annotation. This is used to implement the infoview for the conv mode.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              This version of mkLHSGoal does not check that the argument is an equality.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Return some lhs if e = mkLHSGoal e', where e' is of the form lhs = rhs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Polymorphic operation for generating unique/fresh free variable identifiers. It is available in any monad m that implements the interface MonadNameGenerator.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Polymorphic operation for generating unique/fresh metavariable identifiers. It is available in any monad m that implements the interface MonadNameGenerator.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Polymorphic operation for generating unique/fresh universe metavariable identifiers. It is available in any monad m that implements the interface MonadNameGenerator.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.mkNot (p : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Return Not p

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.mkOr (p q : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Return p ∨ q

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.mkAnd (p q : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Return p ∧ q

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Make an n-ary And application. mkAndN [] returns True.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.mkEM (p : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Returns Classical.em p

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.mkIff (p q : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Returns p ↔ q

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Constants for Nat typeclasses.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Given a : Nat, returns Nat.succ a

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.mkNatAdd (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Given a b : Nat, returns a + b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.mkNatSub (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Given a b : Nat, returns a - b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.mkNatMul (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Given a b : Nat, returns a * b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.mkNatPow (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Given a b : Nat, returns a ^ b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.mkNatLE (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Given a b : Nat, return a ≤ b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.mkNatEq (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Given a b : Nat, return a = b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def Lean.mkPropEq (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Given a b : Prop, returns a = b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Constants for Int typeclasses.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Given a : Int, returns - a

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.mkIntAdd (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Given a b : Int, returns a + b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.mkIntSub (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Given a b : Int, returns a - b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.mkIntMul (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Given a b : Int, returns a * b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def Lean.mkIntDiv (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Given a b : Int, returns a / b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    def Lean.mkIntMod (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Given a b : Int, returns a % b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Given a : Nat, returns NatCast.natCast (R := Int) a

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Given a b : Int, returns a ^ b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          def Lean.mkIntLE (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Given a b : Int, returns a ≤ b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def Lean.mkIntLT (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Given a b : Int, returns a < b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              def Lean.mkIntEq (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Given a b : Int, returns a = b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                def Lean.mkIntDvd (a b : Expr) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Given a b : Int, returns a ∣ b

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        def Lean.Expr.replaceFn (e : Expr) (declName : Name) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Replaces the head constant in a function application chain with a different constant.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Given an expression that is either a constant or a function application chain, replaces the head constant with declName while preserving all arguments and universe levels.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Examples:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Panics: If the expression is neither a constant nor a function application.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Use case: Useful for substituting one function for another while maintaining the same application structure, such as replacing a theorem with a related theorem that has the same type and universe parameters.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For