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

full_name: commandDeclare_uint_simprocs_
code: macro "declare_uint_simprocs" typeName:ident : command =>
let ofNat := typeName.getId ++ `ofNat
let ofNatCore := mkIdent (typeName.getId ++ `ofNatCore)
let toNat := mkIdent (typeName.getId ++ `toNat)
let fromExpr := mkIdent `fromExpr
`(
namespace $typeName

def $fromExpr (e : Expr) : SimpM (Option $typeName) := do
  let some (n, _) ← getOfNatValue? e $(quote typeName.getId) | return none
  return $(mkIdent ofNat) n

@[inline] def reduceBin (declName : Name) (arity : Nat) (op : $typeName → $typeName → $typeName) (e : Expr) : SimpM DStep := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  return .done <| toExpr (op n m)

@[inline] def reduceBinPred (declName : Name) (arity : Nat) (op : $typeName → $typeName → Bool) (e : Expr) : SimpM Step := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  evalPropStep e (op n m)

@[inline] def reduceBoolPred (declName : Name) (arity : Nat) (op : $typeName → $typeName → Bool) (e : Expr) : SimpM DStep := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  return .done <| toExpr (op n m)

builtin_dsimproc [simp, seval] $(mkIdent `reduceAdd):ident ((_ + _ : $typeName)) := reduceBin ``HAdd.hAdd 6 (· + ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceMul):ident ((_ * _ : $typeName)) := reduceBin ``HMul.hMul 6 (· * ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceSub):ident ((_ - _ : $typeName)) := reduceBin ``HSub.hSub 6 (· - ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceDiv):ident ((_ / _ : $typeName)) := reduceBin ``HDiv.hDiv 6 (· / ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceMod):ident ((_ % _ : $typeName)) := reduceBin ``HMod.hMod 6 (· % ·)

builtin_simproc [simp, seval] $(mkIdent `reduceLT):ident  (( _ : $typeName) < _)  := reduceBinPred ``LT.lt 4 (. < .)
builtin_simproc [simp, seval] $(mkIdent `reduceLE):ident  (( _ : $typeName) ≤ _)  := reduceBinPred ``LE.le 4 (. ≤ .)
builtin_simproc [simp, seval] $(mkIdent `reduceGT):ident  (( _ : $typeName) > _)  := reduceBinPred ``GT.gt 4 (. > .)
builtin_simproc [simp, seval] $(mkIdent `reduceGE):ident  (( _ : $typeName) ≥ _)  := reduceBinPred ``GE.ge 4 (. ≥ .)
builtin_simproc [simp, seval] reduceEq  (( _ : $typeName) = _)  := reduceBinPred ``Eq 3 (. = .)
builtin_simproc [simp, seval] reduceNe  (( _ : $typeName) ≠ _)  := reduceBinPred ``Ne 3 (. ≠ .)
builtin_dsimproc [simp, seval] reduceBEq  (( _ : $typeName) == _)  := reduceBoolPred ``BEq.beq 4 (. == .)
builtin_dsimproc [simp, seval] reduceBNe  (( _ : $typeName) != _)  := reduceBoolPred ``bne 4 (. != .)

builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNatCore):ident ($ofNatCore _ _) := fun e => do
  unless e.isAppOfArity $(quote ofNatCore.getId) 2 do return .continue
  let some value ← Nat.fromExpr? e.appFn!.appArg! | return .continue
  let value := $(mkIdent ofNat) value
  return .done <| toExpr value

builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNat):ident ($(mkIdent ofNat) _) := fun e => do
  unless e.isAppOfArity $(quote ofNat) 1 do return .continue
  let some value ← Nat.fromExpr? e.appArg! | return .continue
  let value := $(mkIdent ofNat) value
  return .done <| toExpr value

builtin_dsimproc [simp, seval] $(mkIdent `reduceToNat):ident ($toNat _) := fun e => do
  unless e.isAppOfArity $(quote toNat.getId) 1 do return .continue
  let some v ← ($fromExpr e.appArg!) | return .continue
  let n := $toNat v
  return .done <| toExpr n

/-- Return `.done` for UInt values. We don't want to unfold in the symbolic evaluator. -/
builtin_dsimproc [seval] isValue ((OfNat.ofNat _ : $typeName)) := fun e => do
  unless (e.isAppOfArity ``OfNat.ofNat 3) do return .continue
  return .done e

end $typeName
)
goal: Lean.ParserDescr

full_name: «_aux_.lake_packages_lean4_src_lean_Lean_Meta_Tactic_Simp_BuiltinSimprocs_UInt___macroRules_commandDeclare_uint_simprocs__1»
code: macro "declare_uint_simprocs" typeName:ident : command =>
let ofNat := typeName.getId ++ `ofNat
let ofNatCore := mkIdent (typeName.getId ++ `ofNatCore)
let toNat := mkIdent (typeName.getId ++ `toNat)
let fromExpr := mkIdent `fromExpr
`(
namespace $typeName

def $fromExpr (e : Expr) : SimpM (Option $typeName) := do
  let some (n, _) ← getOfNatValue? e $(quote typeName.getId) | return none
  return $(mkIdent ofNat) n

@[inline] def reduceBin (declName : Name) (arity : Nat) (op : $typeName → $typeName → $typeName) (e : Expr) : SimpM DStep := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  return .done <| toExpr (op n m)

@[inline] def reduceBinPred (declName : Name) (arity : Nat) (op : $typeName → $typeName → Bool) (e : Expr) : SimpM Step := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  evalPropStep e (op n m)

@[inline] def reduceBoolPred (declName : Name) (arity : Nat) (op : $typeName → $typeName → Bool) (e : Expr) : SimpM DStep := do
  unless e.isAppOfArity declName arity do return .continue
  let some n ← ($fromExpr e.appFn!.appArg!) | return .continue
  let some m ← ($fromExpr e.appArg!) | return .continue
  return .done <| toExpr (op n m)

builtin_dsimproc [simp, seval] $(mkIdent `reduceAdd):ident ((_ + _ : $typeName)) := reduceBin ``HAdd.hAdd 6 (· + ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceMul):ident ((_ * _ : $typeName)) := reduceBin ``HMul.hMul 6 (· * ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceSub):ident ((_ - _ : $typeName)) := reduceBin ``HSub.hSub 6 (· - ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceDiv):ident ((_ / _ : $typeName)) := reduceBin ``HDiv.hDiv 6 (· / ·)
builtin_dsimproc [simp, seval] $(mkIdent `reduceMod):ident ((_ % _ : $typeName)) := reduceBin ``HMod.hMod 6 (· % ·)

builtin_simproc [simp, seval] $(mkIdent `reduceLT):ident  (( _ : $typeName) < _)  := reduceBinPred ``LT.lt 4 (. < .)
builtin_simproc [simp, seval] $(mkIdent `reduceLE):ident  (( _ : $typeName) ≤ _)  := reduceBinPred ``LE.le 4 (. ≤ .)
builtin_simproc [simp, seval] $(mkIdent `reduceGT):ident  (( _ : $typeName) > _)  := reduceBinPred ``GT.gt 4 (. > .)
builtin_simproc [simp, seval] $(mkIdent `reduceGE):ident  (( _ : $typeName) ≥ _)  := reduceBinPred ``GE.ge 4 (. ≥ .)
builtin_simproc [simp, seval] reduceEq  (( _ : $typeName) = _)  := reduceBinPred ``Eq 3 (. = .)
builtin_simproc [simp, seval] reduceNe  (( _ : $typeName) ≠ _)  := reduceBinPred ``Ne 3 (. ≠ .)
builtin_dsimproc [simp, seval] reduceBEq  (( _ : $typeName) == _)  := reduceBoolPred ``BEq.beq 4 (. == .)
builtin_dsimproc [simp, seval] reduceBNe  (( _ : $typeName) != _)  := reduceBoolPred ``bne 4 (. != .)

builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNatCore):ident ($ofNatCore _ _) := fun e => do
  unless e.isAppOfArity $(quote ofNatCore.getId) 2 do return .continue
  let some value ← Nat.fromExpr? e.appFn!.appArg! | return .continue
  let value := $(mkIdent ofNat) value
  return .done <| toExpr value

builtin_dsimproc [simp, seval] $(mkIdent `reduceOfNat):ident ($(mkIdent ofNat) _) := fun e => do
  unless e.isAppOfArity $(quote ofNat) 1 do return .continue
  let some value ← Nat.fromExpr? e.appArg! | return .continue
  let value := $(mkIdent ofNat) value
  return .done <| toExpr value

builtin_dsimproc [simp, seval] $(mkIdent `reduceToNat):ident ($toNat _) := fun e => do
  unless e.isAppOfArity $(quote toNat.getId) 1 do return .continue
  let some v ← ($fromExpr e.appArg!) | return .continue
  let n := $toNat v
  return .done <| toExpr n

/-- Return `.done` for UInt values. We don't want to unfold in the symbolic evaluator. -/
builtin_dsimproc [seval] isValue ((OfNat.ofNat _ : $typeName)) := fun e => do
  unless (e.isAppOfArity ``OfNat.ofNat 3) do return .continue
  return .done e

end $typeName
)
goal: Lean.Macro

full_name: UInt8.reduceNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Meta.Simp.Simproc

full_name: UInt8.reduceEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Meta.Simp.Simproc

full_name: UInt8.isValue._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Meta.Simp.DSimproc

full_name: UInt8.reduceBEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Meta.Simp.DSimproc

full_name: UInt8.reduceBinPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Name → Nat → (UInt8 → UInt8 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: UInt8.reduceBin._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Name → Nat → (UInt8 → UInt8 → UInt8) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt8.reduceBNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Meta.Simp.DSimproc

full_name: UInt8.reduceBoolPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.7783
code: declare_uint_simprocs UInt8
goal: Lean.Name → Nat → (UInt8 → UInt8 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt16.isValue._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Meta.Simp.DSimproc

full_name: UInt16.reduceEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Meta.Simp.Simproc

full_name: UInt16.reduceBNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Meta.Simp.DSimproc

full_name: UInt16.reduceBinPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Name → Nat → (UInt16 → UInt16 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: UInt16.reduceBEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Meta.Simp.DSimproc

full_name: UInt16.reduceBoolPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Name → Nat → (UInt16 → UInt16 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt16.reduceBin._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Name → Nat → (UInt16 → UInt16 → UInt16) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt16.reduceNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.9242
code: declare_uint_simprocs UInt16
goal: Lean.Meta.Simp.Simproc

full_name: UInt32.reduceBEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Meta.Simp.DSimproc

full_name: UInt32.reduceBoolPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Name → Nat → (UInt32 → UInt32 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt32.reduceBNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Meta.Simp.DSimproc

full_name: UInt32.reduceBinPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Name → Nat → (UInt32 → UInt32 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: UInt32.isValue._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Meta.Simp.DSimproc

full_name: UInt32.reduceNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Meta.Simp.Simproc

full_name: UInt32.reduceEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Meta.Simp.Simproc

full_name: UInt32.reduceBin._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.10701
code: declare_uint_simprocs UInt32
goal: Lean.Name → Nat → (UInt32 → UInt32 → UInt32) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt64.reduceBinPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Name → Nat → (UInt64 → UInt64 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: UInt64.reduceBNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Meta.Simp.DSimproc

full_name: UInt64.reduceBEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Meta.Simp.DSimproc

full_name: UInt64.isValue._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Meta.Simp.DSimproc

full_name: UInt64.reduceBin._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Name → Nat → (UInt64 → UInt64 → UInt64) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt64.reduceBoolPred._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Name → Nat → (UInt64 → UInt64 → Bool) → Lean.Expr → Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: UInt64.reduceEq._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Meta.Simp.Simproc

full_name: UInt64.reduceNe._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.BuiltinSimprocs.UInt._hyg.12160
code: declare_uint_simprocs UInt64
goal: Lean.Meta.Simp.Simproc