File: .lake/packages/lean4/src/lean/Lean/Meta/Tactic/Simp/BuiltinSimprocs/Fin.lean

full_name: Fin.Value.n
code: structure Value where
  n     : Nat
  value : Fin n
  deriving DecidableEq, Repr
goal: Nat

full_name: Fin.Value
code: structure Value where
  n     : Nat
  value : Fin n
  deriving DecidableEq, Repr
goal: Type

full_name: Fin.Value.value
code: structure Value where
  n     : Nat
  value : Fin n
  deriving DecidableEq, Repr
goal: Fin self.n

full_name: Fin.instReprValue
code: structure Value where
  n     : Nat
  value : Fin n
  deriving DecidableEq, Repr
goal: Repr Fin.Value

full_name: Fin.fromExpr?
code: def fromExpr? (e : Expr) : SimpM (Option Value) 
goal: Lean.Meta.SimpM (Option Fin.Value)

full_name: Fin.reduceBin
code: @[inline] def reduceBin (declName : Name) (arity : Nat) (op : {n : Nat} → Fin n → Fin n → Fin n) (e : Expr) : SimpM DStep 
goal: Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: Fin.reduceBinPred
code: @[inline] def reduceBinPred (declName : Name) (arity : Nat) (op : Nat → Nat → Bool) (e : Expr) : SimpM Step 
goal: Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: Fin.reduceBoolPred
code: @[inline] def reduceBoolPred (declName : Name) (arity : Nat) (op : Nat → Nat → Bool) (e : Expr) : SimpM DStep 
goal: Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: Fin.reduceAdd
code: builtin_dsimproc [simp, seval] reduceAdd ((_ + _ : Fin _)) := reduceBin ``HAdd.hAdd 6 (· + ·)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceMul
code: builtin_dsimproc [simp, seval] reduceMul ((_ * _ : Fin _)) := reduceBin ``HMul.hMul 6 (· * ·)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceSub
code: builtin_dsimproc [simp, seval] reduceSub ((_ - _ : Fin _)) := reduceBin ``HSub.hSub 6 (· - ·)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceDiv
code: builtin_dsimproc [simp, seval] reduceDiv ((_ / _ : Fin _)) := reduceBin ``HDiv.hDiv 6 (· / ·)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceMod
code: builtin_dsimproc [simp, seval] reduceMod ((_ % _ : Fin _)) := reduceBin ``HMod.hMod 6 (· % ·)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceLT
code: builtin_simproc [simp, seval] reduceLT  (( _ : Fin _) < _)  := reduceBinPred ``LT.lt 4 (. < .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceLE
code: builtin_simproc [simp, seval] reduceLE  (( _ : Fin _) ≤ _)  := reduceBinPred ``LE.le 4 (. ≤ .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceGT
code: builtin_simproc [simp, seval] reduceGT  (( _ : Fin _) > _)  := reduceBinPred ``GT.gt 4 (. > .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceGE
code: builtin_simproc [simp, seval] reduceGE  (( _ : Fin _) ≥ _)  := reduceBinPred ``GE.ge 4 (. ≥ .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceEq
code: builtin_simproc [simp, seval] reduceEq  (( _ : Fin _) = _)  := reduceBinPred ``Eq 3 (. = .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceNe
code: builtin_simproc [simp, seval] reduceNe  (( _ : Fin _) ≠ _)  := reduceBinPred ``Ne 3 (. ≠ .)
goal: Lean.Meta.Simp.Simproc

full_name: Fin.reduceBEq
code: builtin_dsimproc [simp, seval] reduceBEq  (( _ : Fin _) == _)  := reduceBoolPred ``BEq.beq 4 (. == .)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceBNe
code: builtin_dsimproc [simp, seval] reduceBNe  (( _ : Fin _) != _)  := reduceBoolPred ``bne 4 (. != .)
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.isValue
code: /-- Simplification procedure for ensuring `Fin` literals are normalized. -/
builtin_dsimproc [simp, seval] isValue ((OfNat.ofNat _ : Fin _)) := fun e => do
  let some ⟨n, v⟩ ← getFinValue? e | return .continue
  let some m ← getNatValue? e.appFn!.appArg! | return .continue
  if n == m then
    -- Design decision: should we return `.continue` instead of `.done` when simplifying.
    -- In the symbolic evaluator, we must return `.done`, otherwise it will unfold the `OfNat.ofNat`
    return .done e
  return .done <| toExpr v
goal: Lean.Meta.Simp.DSimproc

full_name: Fin.reduceFinMk
code: builtin_dsimproc [simp, seval] reduceFinMk (Fin.mk _ _)  := fun e => do
  let_expr Fin.mk n v _ ← e | return .continue
  let some n ← evalNat n |>.run | return .continue
  let some v ← getNatValue? v | return .continue
  if h : n > 0 then
    return .done <| toExpr (Fin.ofNat' v h)
  else
    return .continue
goal: Lean.Meta.Simp.DSimproc