File: Mathlib/Tactic/SplitIfs.lean

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.SplitPosition.hyp
code: /-- A position where a split may apply.
-/
private inductive SplitPosition
| target
| hyp (fvarId: FVarId)
goal: Mathlib.Tactic.SplitPosition

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.SplitPosition
code: /-- A position where a split may apply.
-/
private inductive SplitPosition
| target
| hyp (fvarId: FVarId)
goal: Type

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.SplitPosition.target
code: /-- A position where a split may apply.
-/
private inductive SplitPosition
| target
| hyp (fvarId: FVarId)
goal: Mathlib.Tactic.SplitPosition

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.getSplitCandidates
code: /-- Collects a list of positions pointed to by `loc` and their types.
-/
private def getSplitCandidates (loc : Location) : TacticM (List (SplitPosition × Expr)) 
goal: Lean.Elab.Tactic.TacticM (List (Mathlib.Tactic.SplitPosition × Lean.Expr))

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.findIfToSplit?
code: /-- Return the condition and decidable instance of an `if` expression to case split. -/
private partial def findIfToSplit? (e : Expr) : Option (Expr × Expr) 
goal: Option (Lean.Expr × Lean.Expr)

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.findIfCondAt
code: /-- Finds an if condition to split. If successful, returns the position and the condition.
-/
private def findIfCondAt (loc : Location) : TacticM (Option (SplitPosition × Expr)) 
goal: Lean.Elab.Tactic.TacticM (Option (Mathlib.Tactic.SplitPosition × Lean.Expr))

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.discharge?
code: /-- `Simp.Discharge` strategy to use in `reduceIfsAt`. Delegates to
`SplitIf.discharge?`, and additionally supports discharging `True`, to
better match the behavior of mathlib3's `split_ifs`.
-/
private def discharge? (e : Expr) : SimpM (Option Expr) 
goal: Lean.Meta.SimpM (Option Lean.Expr)

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.reduceIfsAt
code: /-- Simplifies if-then-else expressions after cases have been split out.
-/
private def reduceIfsAt (loc : Location) : TacticM Unit 
goal: Lean.Elab.Tactic.TacticM Unit

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.splitIf1
code: /-- Splits a single if-then-else expression and then reduces the resulting goals.
Has a similar effect as `SplitIf.splitIfTarget?` or `SplitIf.splitIfLocalDecl?` from
core Lean 4. We opt not to use those library functions so that we can better mimic
the behavior of mathlib3's `split_ifs`.
-/
private def splitIf1 (cond : Expr) (hName : Name) (loc : Location) : TacticM Unit 
goal: Lean.Elab.Tactic.TacticM Unit

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.getNextName
code: /-- Pops off the front of the list of names, or generates a fresh name if the
list is empty.
-/
private def getNextName (hNames: IO.Ref (List (TSyntax `Lean.binderIdent))) : MetaM Name 
goal: Lean.MetaM Lean.Name

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.valueKnown
code: /-- Returns `true` if the condition or its negation already appears as a hypothesis.
-/
private def valueKnown (cond : Expr) : TacticM Bool 
goal: Lean.Elab.Tactic.TacticM Bool

full_name: _private.Mathlib.Tactic.SplitIfs.0.Mathlib.Tactic.splitIfsCore
code: /-- Main loop of split_ifs. Pulls names for new hypotheses from `hNames`.
Stops if it encounters a condition in the passed-in `List Expr`.
-/
private partial def splitIfsCore
    (loc : Location)
    (hNames : IO.Ref (List (TSyntax `Lean.binderIdent))) :
    List Expr → TacticM Unit 
goal: List Lean.Expr → Lean.Elab.Tactic.TacticM Unit

full_name: Mathlib.Tactic.splitIfs
code: /-- Splits all if-then-else-expressions into multiple goals.
Given a goal of the form `g (if p then x else y)`, `split_ifs` will produce
two goals: `p ⊢ g x` and `¬p ⊢ g y`.
If there are multiple ite-expressions, then `split_ifs` will split them all,
starting with a top-most one whose condition does not contain another
ite-expression.
`split_ifs at *` splits all ite-expressions in all hypotheses as well as the goal.
`split_ifs with h₁ h₂ h₃` overrides the default names for the hypotheses.
-/
syntax (name := splitIfs) "split_ifs" (location)? (" with" (ppSpace colGt binderIdent)+)? : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_SplitIfs___elabRules_Mathlib_Tactic_splitIfs_1
code: elab_rules : tactic
| `(tactic| split_ifs $[$loc:location]? $[with $withArg*]?) =>
  let loc := match loc with
  | none => Location.targets #[] true
  | some loc => expandLocation loc
  let names := match withArg with
  | none => []
  | some args => args.toList
  withMainContext do
    let names ← IO.mkRef names
    splitIfsCore loc names []
    for name in ← names.get do
      logWarningAt name m!"unused name: {name}"
goal: Lean.Elab.Tactic.Tactic