File: .lake/packages/lean4/src/lean/Lean/SubExpr.lean

full_name: Lean.SubExpr.Pos
code: /-- A position of a subexpression in an expression.

We use a simple encoding scheme for expression positions `Pos`:
every `Expr` constructor has at most 3 direct expression children. Considering an expression's type
to be one extra child as well, we can injectively map a path of `childIdxs` to a natural number
by computing the value of the 4-ary representation `1 :: childIdxs`, since n-ary representations
without leading zeros are unique. Note that `pos` is initialized to `1` (case `childIdxs == []`).

See also `SubExpr`. -/
def SubExpr.Pos 
goal: Type

full_name: Lean.SubExpr.Pos.maxChildren
code: def maxChildren 
goal: Nat

full_name: Lean.SubExpr.Pos.typeCoord
code: /-- The coordinate `3 = maxChildren - 1` is
reserved to denote the type of the expression. -/
def typeCoord : Nat 
goal: Nat

full_name: Lean.SubExpr.Pos.asNat
code: def asNat : Pos → Nat 
goal: Lean.SubExpr.Pos → Nat

full_name: Lean.SubExpr.Pos.root
code: /-- The Pos representing the root subexpression. -/
def root : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instInhabited
code: instance : Inhabited Pos 
goal: Inhabited Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.isRoot
code: def isRoot (p : Pos) : Bool 
goal: Bool

full_name: Lean.SubExpr.Pos.head
code: /-- The coordinate deepest in the Pos. -/
def head (p : Pos) : Nat 
goal: Nat

full_name: Lean.SubExpr.Pos.tail
code: def tail (p : Pos) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.push
code: def push (p : Pos) (c : Nat) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.foldl
code: /-- Fold over the position starting at the root and heading to the leaf-/
partial def foldl  (f : α → Nat → α) (init : α) (p : Pos) : α 
goal: α

full_name: Lean.SubExpr.Pos.foldr
code: /-- Fold over the position starting at the leaf and heading to the root-/
partial def foldr  (f : Nat → α → α) (p : Pos) (init : α) : α 
goal: α

full_name: Lean.SubExpr.Pos.foldlM
code: /-- monad-fold over the position starting at the root and heading to the leaf -/
partial def foldlM  [Monad M] (f : α → Nat → M α) (init : α) (p : Pos) : M α 
goal: M α

full_name: Lean.SubExpr.Pos.foldrM
code: /-- monad-fold over the position starting at the leaf and finishing at the root. -/
partial def foldrM [Monad M] (f : Nat → α → M α) (p : Pos) (init : α) : M α 
goal: M α

full_name: Lean.SubExpr.Pos.depth
code: def depth (p : Pos) 
goal: Nat

full_name: Lean.SubExpr.Pos.all
code: /-- Returns true if `pred` is true for each coordinate in `p`.-/
def all (pred : Nat → Bool) (p : Pos) : Bool 
goal: Bool

full_name: Lean.SubExpr.Pos.append
code: def append : Pos → Pos → Pos 
goal: Lean.SubExpr.Pos → Lean.SubExpr.Pos → Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.ofArray
code: /-- Creates a subexpression `Pos` from an array of 'coordinates'.
Each coordinate is a number {0,1,2} expressing which child subexpression should be explored.
The first coordinate in the array corresponds to the root of the expression tree.  -/
def ofArray (ps : Array Nat) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.toArray
code: /-- Decodes a subexpression `Pos` as a sequence of coordinates `cs : Array Nat`. See `Pos.ofArray` for details.
`cs[0]` is the coordinate for the root expression. -/
def toArray (p : Pos) : Array Nat 
goal: Array Nat

full_name: Lean.SubExpr.Pos.pushBindingDomain
code: def pushBindingDomain (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushBindingBody
code: def pushBindingBody   (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushLetVarType
code: def pushLetVarType    (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushLetValue
code: def pushLetValue      (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushLetBody
code: def pushLetBody       (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushAppFn
code: def pushAppFn         (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushAppArg
code: def pushAppArg        (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushProj
code: def pushProj          (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushType
code: def pushType          (p : Pos) 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushNaryFn
code: def pushNaryFn (numArgs : Nat) (p : Pos) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushNaryArg
code: def pushNaryArg (numArgs argIdx : Nat) (p : Pos) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushNthBindingDomain
code: def pushNthBindingDomain : (binderIdx : Nat) → Pos → Pos
  
goal: Lean.SubExpr.Pos → Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.pushNthBindingBody
code: def pushNthBindingBody : (numBinders : Nat) → Pos → Pos
  
goal: Lean.SubExpr.Pos → Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.toString
code: protected def toString (p : Pos) : String 
goal: String

full_name: _private.«.lake».packages.lean4.src.lean.Lean.SubExpr.0.Lean.SubExpr.Pos.ofStringCoord
code: private def ofStringCoord : String → Except String Nat
  
goal: String → Except String Nat

full_name: Lean.SubExpr.Pos.fromString?
code: protected def fromString? : String → Except String Pos
  
goal: String → Except String Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.fromString!
code: protected def fromString! (s : String) : Pos 
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instOrd
code: instance : Ord Pos 
goal: Ord Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instDecidableEq
code: instance : DecidableEq Pos 
goal: DecidableEq Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instToString
code: instance : ToString Pos 
goal: ToString Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instEmptyCollection
code: instance : EmptyCollection Pos 
goal: EmptyCollection Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instRepr
code: instance : Repr Pos 
goal: Repr Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instToJson
code: instance : ToJson Pos 
goal: Lean.ToJson Lean.SubExpr.Pos

full_name: Lean.SubExpr.Pos.instFromJson
code: instance : FromJson Pos 
goal: Lean.FromJson Lean.SubExpr.Pos

full_name: Lean.SubExpr.expr
code: /-- A subexpression of some root expression. Both its value and its position
within the root are stored. -/
structure SubExpr where
  /-- The subexpression. -/
  expr : Expr
  /-- The position of the subexpression within the root expression. -/
  pos  : SubExpr.Pos
  deriving Inhabited
goal: Lean.Expr

full_name: Lean.instInhabitedSubExpr
code: /-- A subexpression of some root expression. Both its value and its position
within the root are stored. -/
structure SubExpr where
  /-- The subexpression. -/
  expr : Expr
  /-- The position of the subexpression within the root expression. -/
  pos  : SubExpr.Pos
  deriving Inhabited
goal: Inhabited Lean.SubExpr

full_name: Lean.SubExpr
code: /-- A subexpression of some root expression. Both its value and its position
within the root are stored. -/
structure SubExpr where
  /-- The subexpression. -/
  expr : Expr
  /-- The position of the subexpression within the root expression. -/
  pos  : SubExpr.Pos
  deriving Inhabited
goal: Type

full_name: Lean.SubExpr.pos
code: /-- A subexpression of some root expression. Both its value and its position
within the root are stored. -/
structure SubExpr where
  /-- The subexpression. -/
  expr : Expr
  /-- The position of the subexpression within the root expression. -/
  pos  : SubExpr.Pos
  deriving Inhabited
goal: Lean.SubExpr.Pos

full_name: Lean.SubExpr.mkRoot
code: def mkRoot (e : Expr) : SubExpr 
goal: Lean.SubExpr

full_name: Lean.SubExpr.isRoot
code: /-- Returns true if the selected subexpression is the topmost one. -/
def isRoot (s : SubExpr) : Bool 
goal: Bool

full_name: Lean.SubExpr.PosMap
code: /-- Map from subexpr positions to values. -/
abbrev PosMap (α : Type u) 
goal: Type u

full_name: Lean.SubExpr.bindingBody!
code: def bindingBody! : SubExpr → SubExpr
  
goal: Lean.SubExpr → Lean.SubExpr

full_name: Lean.SubExpr.bindingDomain!
code: def bindingDomain! : SubExpr → SubExpr
  
goal: Lean.SubExpr → Lean.SubExpr

full_name: Lean.SubExpr.instToJsonFVarId
code: instance : ToJson FVarId 
goal: Lean.ToJson Lean.FVarId

full_name: Lean.SubExpr.instToJsonMVarId
code: instance : ToJson MVarId 
goal: Lean.ToJson Lean.MVarId

full_name: Lean.SubExpr.instFromJsonFVarId
code: instance : FromJson FVarId 
goal: Lean.FromJson Lean.FVarId

full_name: Lean.SubExpr.instFromJsonMVarId
code: instance : FromJson MVarId 
goal: Lean.FromJson Lean.MVarId

full_name: Lean.SubExpr.GoalLocation.hypType
code: /-- A location within a goal. -/
inductive GoalLocation where
  /-- One of the hypotheses. -/
  | hyp : FVarId → GoalLocation
  /-- A subexpression of the type of one of the hypotheses. -/
  | hypType : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the value of one of the let-bound hypotheses. -/
  | hypValue : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the goal type. -/
  | target : SubExpr.Pos → GoalLocation
  deriving FromJson, ToJson
goal: Lean.FVarId → Lean.SubExpr.Pos → Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.GoalLocation.hyp
code: /-- A location within a goal. -/
inductive GoalLocation where
  /-- One of the hypotheses. -/
  | hyp : FVarId → GoalLocation
  /-- A subexpression of the type of one of the hypotheses. -/
  | hypType : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the value of one of the let-bound hypotheses. -/
  | hypValue : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the goal type. -/
  | target : SubExpr.Pos → GoalLocation
  deriving FromJson, ToJson
goal: Lean.FVarId → Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.GoalLocation.target
code: /-- A location within a goal. -/
inductive GoalLocation where
  /-- One of the hypotheses. -/
  | hyp : FVarId → GoalLocation
  /-- A subexpression of the type of one of the hypotheses. -/
  | hypType : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the value of one of the let-bound hypotheses. -/
  | hypValue : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the goal type. -/
  | target : SubExpr.Pos → GoalLocation
  deriving FromJson, ToJson
goal: Lean.SubExpr.Pos → Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.GoalLocation
code: /-- A location within a goal. -/
inductive GoalLocation where
  /-- One of the hypotheses. -/
  | hyp : FVarId → GoalLocation
  /-- A subexpression of the type of one of the hypotheses. -/
  | hypType : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the value of one of the let-bound hypotheses. -/
  | hypValue : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the goal type. -/
  | target : SubExpr.Pos → GoalLocation
  deriving FromJson, ToJson
goal: Type

full_name: Lean.SubExpr.GoalLocation.hypValue
code: /-- A location within a goal. -/
inductive GoalLocation where
  /-- One of the hypotheses. -/
  | hyp : FVarId → GoalLocation
  /-- A subexpression of the type of one of the hypotheses. -/
  | hypType : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the value of one of the let-bound hypotheses. -/
  | hypValue : FVarId → SubExpr.Pos → GoalLocation
  /-- A subexpression of the goal type. -/
  | target : SubExpr.Pos → GoalLocation
  deriving FromJson, ToJson
goal: Lean.FVarId → Lean.SubExpr.Pos → Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.instFromJsonGoalLocation
code: FromJson
goal: Lean.FromJson Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.instToJsonGoalLocation
code: ToJson
goal: Lean.ToJson Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.GoalsLocation.mvarId
code: /-- A location within a goal state. It identifies a specific goal together with a `GoalLocation`
within it. -/
structure GoalsLocation where
  /-- Which goal the location is in. -/
  mvarId : MVarId
  loc    : GoalLocation
  deriving FromJson, ToJson
goal: Lean.MVarId

full_name: Lean.SubExpr.GoalsLocation
code: /-- A location within a goal state. It identifies a specific goal together with a `GoalLocation`
within it. -/
structure GoalsLocation where
  /-- Which goal the location is in. -/
  mvarId : MVarId
  loc    : GoalLocation
  deriving FromJson, ToJson
goal: Type

full_name: Lean.SubExpr.GoalsLocation.loc
code: /-- A location within a goal state. It identifies a specific goal together with a `GoalLocation`
within it. -/
structure GoalsLocation where
  /-- Which goal the location is in. -/
  mvarId : MVarId
  loc    : GoalLocation
  deriving FromJson, ToJson
goal: Lean.SubExpr.GoalLocation

full_name: Lean.SubExpr.instFromJsonGoalsLocation
code: FromJson
goal: Lean.FromJson Lean.SubExpr.GoalsLocation

full_name: Lean.SubExpr.instToJsonGoalsLocation
code: ToJson
goal: Lean.ToJson Lean.SubExpr.GoalsLocation

full_name: Lean.Expr.traverseAppWithPos
code: /-- Same as `Expr.traverseApp` but also includes a
`SubExpr.Pos` argument for tracking subexpression position. -/
def Expr.traverseAppWithPos {M} [Monad M] (visit : Pos → Expr → M Expr) (p : Pos) (e : Expr) : M Expr 
goal: M Lean.Expr