14.2.4.3.Β Arithmetic
Typically, arithmetic operations on integers are accessed using Lean's overloaded arithmetic notation.
In particular, the instances of Add Int
, Neg Int
, Sub Int
, and Mul Int
allow ordinary infix operators to be used.
Division is somewhat more intricate, because there are multiple sensible notions of division on integers.
πdefInt.add (m n : Int) : Int
Addition of two integers.
13
#eval (7 : Int) + (6 : Int) -- 13
0
#eval (6 : Int) + (-6 : Int) -- 0
Implemented by efficient native code.
πdefInt.subNatNat (m n : Nat) : Int
Subtraction of two natural numbers.
πdefInt.neg (n : Int) : Int
Negation of an integer.
Implemented by efficient native code.
πdefInt.negOfNat : Nat β Int
Negation of a natural number.
πdefInt.gcd (m n : Int) : Nat
Computes the greatest common divisor of two integers, as a Nat
.
πdefInt.lcm (m n : Int) : Nat
Computes the least common multiple of two integers, as a Nat
.
14.2.4.6.Β Proof Automation
The functions in this section are primarily parts of the implementation of simplification rules employed by simp
.
They are probably only of interest to users who are implementing custom proof automation that involves integers.
πdefInt.fromExpr? (e : Lean.Expr) :
Lean.Meta.SimpM (Option Int)
πdefInt.isPosValue : Lean.Meta.Simp.DSimproc
Return .done
for positive Int values. We don't want to unfold in the symbolic evaluator.
πdefInt.reduceAbs : Lean.Meta.Simp.DSimproc
πdefInt.reduceAdd : Lean.Meta.Simp.DSimproc
πdefInt.reduceBEq : Lean.Meta.Simp.DSimproc
πdefInt.reduceBNe : Lean.Meta.Simp.DSimproc
πdefInt.reduceBdiv : Lean.Meta.Simp.DSimproc
πdefInt.reduceBin (declName : Lean.Name)
(arity : Nat) (op : Int β Int β Int)
(e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.DStep
πdefInt.reduceBinIntNatOp (name : Lean.Name)
(op : Int β Nat β Int) (e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.DStep
πdefInt.reduceBinPred (declName : Lean.Name)
(arity : Nat) (op : Int β Int β Bool)
(e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.Step
πdefInt.reduceBmod : Lean.Meta.Simp.DSimproc
πdefInt.reduceBoolPred (declName : Lean.Name)
(arity : Nat) (op : Int β Int β Bool)
(e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.DStep
πdefInt.reduceDiv : Lean.Meta.Simp.DSimproc
πdefInt.reduceDvd : Lean.Meta.Simp.Simproc
πdefInt.reduceEq : Lean.Meta.Simp.Simproc
πdefInt.reduceFDiv : Lean.Meta.Simp.DSimproc
πdefInt.reduceFMod : Lean.Meta.Simp.DSimproc
πdefInt.reduceGE : Lean.Meta.Simp.Simproc
πdefInt.reduceGT : Lean.Meta.Simp.Simproc
πdefInt.reduceLE : Lean.Meta.Simp.Simproc
πdefInt.reduceLT : Lean.Meta.Simp.Simproc
πdefInt.reduceMod : Lean.Meta.Simp.DSimproc
πdefInt.reduceMul : Lean.Meta.Simp.DSimproc
πdefInt.reduceNatCore (declName : Lean.Name)
(op : Int β Nat) (e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.DStep
πdefInt.reduceNe : Lean.Meta.Simp.Simproc
πdefInt.reduceNeg : Lean.Meta.Simp.DSimproc
πdefInt.reduceNegSucc : Lean.Meta.Simp.DSimproc
πdefInt.reduceOfNat : Lean.Meta.Simp.DSimproc
πdefInt.reducePow : Lean.Meta.Simp.DSimproc
πdefInt.reduceSub : Lean.Meta.Simp.DSimproc
πdefInt.reduceTDiv : Lean.Meta.Simp.DSimproc
πdefInt.reduceTMod : Lean.Meta.Simp.DSimproc
πdefInt.reduceToNat : Lean.Meta.Simp.DSimproc
πdefInt.reduceUnary (declName : Lean.Name)
(arity : Nat) (op : Int β Int)
(e : Lean.Expr) :
Lean.Meta.SimpM Lean.Meta.Simp.DStep