Additional operations on Expr and related types #
This file defines basic operations on the types expr, name, declaration, level, environment.
This file is mostly for non-tactics.
Declarations about BinderInfo #
The brackets corresponding to a given BinderInfo.
Equations
Instances For
Declarations about name #
Find the largest prefix n of a Name such that f n != none, then replace this prefix
with the value of f n.
Equations
Instances For
Build a name from components.
For example, from_components [`foo, `bar] becomes `foo.bar.
It is the inverse of Name.components on list of names that have single components.
Equations
Instances For
Update the last component of a name.
Equations
Instances For
Get the last field of a name as a string. Doesn't raise an error when the last component is a numeric field.
Equations
Instances For
isPrefixOf? pre nm returns some post if nm = pre ++ post.
Note that this includes the case where nm has multiple more namespaces.
If pre is not a prefix of nm, it returns none.
Equations
Instances For
Equations
Instances For
Checks whether this ConstantInfo is a definition.
Equations
Instances For
Checks whether this ConstantInfo is a theorem.
Equations
Instances For
Update ConstantVal (the data common to all constructors of ConstantInfo)
in a ConstantInfo.
Equations
Instances For
Update the name of a ConstantInfo.
Equations
Instances For
Update the type of a ConstantInfo.
Equations
Instances For
Update the level parameters of a ConstantInfo.
Equations
Instances For
Update the value of a ConstantInfo, if it has one.
Equations
Instances For
Turn a ConstantInfo into a declaration.
Equations
Instances For
Same as mkConst, but with fresh level metavariables.
Equations
Instances For
Declarations about Expr #
Given f a b c, return #[f a, f a b, f a b c].
Each entry in the array is an Expr.app,
and this array has the same length as the one returned by Lean.Expr.getAppArgs.
Equations
Instances For
Erase proofs in an expression by replacing them with sorrys.
This function replaces all proofs in the expression
and in the types that appear in the expression
by sorryAxs.
The resulting expression has the same type as the old one.
It is useful, e.g., to verify if the proof-irrelevant part of a definition depends on a variable.
Equations
Instances For
If an Expr has the form Type u, then return some u, otherwise none.
Equations
Instances For
isConstantApplication e checks whether e is syntactically an application of the form
(fun xโ โฏ xโ => H) yโ โฏ yโ where H does not contain the variable xโ. In other words,
it does a syntactic check that the expression does not depend on yโ.
Equations
Instances For
Returns true if type is an application of a constant decl for which p decl is true, or a
forall with return type of the same form (i.e. of the form โ (xโ : Xโ) (xโ : Xโ) โฏ, decl .. where
p decl).
Runs cleanupAnnotations on type and forallE bodies, and ignores metadata in applications.
Returns true if type is an application of a constant declName, or a
forall with return type of the same form (i.e. of the form โ (xโ : Xโ) (xโ : Xโ) โฏ, declName ..).
Runs cleanupAnnotations on type and forallE bodies, and ignores metadata in applications.
Equations
Instances For
Gets the indices i (in ascending order) of the binders of a nested .forallE,
(xโ : Aโ) โ (xโ : Aโ) โ โฏ โ X, such that
- the binder
[xแตข : Aแตข]hasinstImplicitbinderInfo p Aแตขistrue- The rest of the type
(xแตขโโ : Aแตขโโ) โ โฏ โ Xdoes not depend onxแตข. (It's in this sense thatxแตข : Aแตขis "unused".)
Note that the argument to p may have loose bvars. This is a performance optimization.
This function runs cleanupAnnotations on each expression before examining it.
We see through lets, and do not increment the index when doing so. This behavior is compatible
with forallBoundedTelescope.
Equations
Instances For
Counts the immediate depth of a nested let expression.
Equations
Instances For
Check that an expression contains no metavariables (after instantiation).
Equations
Instances For
Construct the term of type ฮฑ for a given natural number
(doing typeclass search for the OfNat instance required).
Equations
Instances For
Return some n if e is one of the following
- a nat literal (numeral)
Nat.zeroNat.succ xwhereisNumeral xOfNat.ofNat _ x _whereisNumeral x
Tests is if an expression matches either x โ y or ยฌ (x = y).
If it matches, returns some (type, x, y).
Equations
Instances For
Lean.Expr.le? e takes e : Expr as input.
If e represents a โค b, then it returns some (t, a, b), where t is the Type of a,
otherwise, it returns none.
Equations
Instances For
Lean.Expr.lt? e takes e : Expr as input.
If e represents a < b, then it returns some (t, a, b), where t is the Type of a,
otherwise, it returns none.
Equations
Instances For
Given a proposition ty that is an Eq, Iff, or HEq, returns (tyLhs, lhs, tyRhs, rhs),
where lhs : tyLhs and rhs : tyRhs,
and where lhs is related to rhs by the respective relation.
See also Lean.Expr.iff?, Lean.Expr.eq?, and Lean.Expr.heq?.
Equations
Instances For
Equations
Instances For
Given f aโ aโ ... aโโโ, runs modifier on the ith argument or
returns the original expression if out of bounds.
Equations
Instances For
Given f aโ aโ ... aโโโ, sets the argument on the ith argument to x or
returns the original expression if out of bounds.
Equations
Instances For
Given f aโ aโ ... aโโโ, returns the ith argument or none if out of bounds.
Equations
Instances For
Given f aโ aโ ... aโโโ, runs modifier on the ith argument.
An argument n may be provided which says how many arguments we are expecting e to have.
Equations
Instances For
Traverses an expression e and renames bound variables named old to new.
Equations
Instances For
getBinderName e returns some n if e is an expression of the form โ n, ...
and none otherwise.
Equations
Instances For
Map binder names in a nested forall (aโ : ฮฑโ) โ ... โ (aโ : ฮฑโ) โ _
Equations
Instances For
If e has a structure as type with field fieldName, mkDirectProjection e fieldName creates
the projection expression e.fieldName
Equations
Instances For
If e has a structure as type with field fieldName (either directly or in a parent
structure), mkProjection e fieldName creates the projection expression e.fieldName
Equations
Instances For
If e is a projection of the structure constructor, reduce the projection.
Otherwise returns none. If this function detects that expression is ill-typed, throws an error.
For example, given Prod.fst (x, y), returns some x.
Equations
Instances For
Returns true if e contains a name n where p n is true.
Equations
Instances For
Get the projections that are projections to parent structures. Similar to getParentStructures,
except that this returns the (last component of the) projection names instead of the parent names.