ZFC Integers #
This file provides a construction of the integers in ZFC based on the construction of natural numbers. It follows the usual construction of integers as equivalence classes of pairs of natural numbers.
The theory also comes with usual theorems and arithmetic operations on integers and wraps everything in a commutative ring structure.
Finally, we show that the ZFInt type is in canonical bijection with the type of elements
contained in ZFSet.Int. The bijection is built directly from the projection functions
ZFInt.into and ZFInt.outof — no Schröder–Bernstein, no Classical.choice over a non-empty
set of bijections — so the induced order on {x // x ∈ ZFSet.Int} is well-defined and concrete
inequalities like 0 < 1 are provable.
Equations
- ZFSet.instSetoidZFNatZFNat = { r := ZFSet.zrel, iseqv := ZFSet.zrel_eq }
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
- ZFSet.ZFInt.instZero = { zero := ZFSet.ZFInt.zero }
Equations
- ZFSet.ZFInt.instOne = { one := ZFSet.ZFInt.one }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ZFSet.ZFInt.instAdd = { add := ZFSet.ZFInt.add }
Equations
- n.neg = Quotient.liftOn n (fun (x : ZFSet.ZFNat × ZFSet.ZFNat) => ZFSet.ZFInt.mk (x.2, x.1)) ZFSet.ZFInt.neg._proof_1
Instances For
Equations
- ZFSet.ZFInt.instNeg = { neg := ZFSet.ZFInt.neg }
Equations
- ZFSet.ZFInt.instSub = { sub := ZFSet.ZFInt.sub }
Equations
- ZFSet.ZFInt.nsmul 0 x✝ = 0
- ZFSet.ZFInt.nsmul n.succ x✝ = x✝ + ZFSet.ZFInt.nsmul n x✝
Instances For
Equations
- ZFSet.ZFInt.zsmul (Int.ofNat n_2) x = ZFSet.ZFInt.nsmul n_2 x
- ZFSet.ZFInt.zsmul (Int.negSucc n_2) x = -ZFSet.ZFInt.nsmul (n_2 + 1) x
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ZFSet.ZFInt.instMul = { mul := ZFSet.ZFInt.mul }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- ZFSet.ZFInt.int_le = { le := fun (x y : ZFSet.ZFInt) => x < y ∨ x = y }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
Instances For
Equations
- ZFSet.ofInt (Int.ofNat n_1) = ∅.pair ↑↑n_1
- ZFSet.ofInt (Int.negSucc n_1) = (↑(↑n_1 + 1)).pair ∅
Instances For
Equations
- ZFSet.toZFInt (Int.ofNat n_1) = ZFSet.ZFInt.mk (0, ↑n_1)
- ZFSet.toZFInt (Int.negSucc n_1) = ZFSet.ZFInt.mk (↑n_1 + 1, 0)
Instances For
Equations
- ZFSet.PInt' = PSet.mk (ULift.{?u.1, 0} ℤ) fun (n : ULift.{?u.1, 0} ℤ) => ZFSet.ofInt'✝ n.down
Instances For
Canonical projection from a set-theoretic integer (an element of ZFSet.Int) to its ZFInt
counterpart. Given an element of Int, which by mem_Int_proj' is of the form pair ∅ n or
pair n ∅ for some n ∈ Nat, returns mk (0, n) or mk (n, 0) respectively. The definition is
deterministic and does not depend on Schröder–Bernstein.
Equations
Instances For
Equations
- ZFSet.ZFInt.EmbeddingZFIntInt = { toFun := ZFSet.ZFInt.into, inj' := ZFSet.ZFInt.into.injective }
Instances For
Equations
- ZFSet.ZFInt.EmbeddingIntZFInt = { toFun := ZFSet.ZFInt.outof, inj' := ZFSet.ZFInt.outof.injective }
Instances For
Canonical linear order on the set-theoretic integers, defined as the pullback of the linear order
on ZFInt along the canonical projection outof. With this definition, statements like 0 < 1
on {x // x ∈ Int} reduce to the corresponding statements on ZFInt, so they are decidable —
unlike the previous Schröder–Bernstein-based definition, which made specific instances of <
unprovable.
Equations
- One or more equations did not get rendered due to their size.
The type ZFInt is in canonical bijection with the subtype {x // x ∈ ZFSet.Int}. The
equivalence is built directly from ZFInt.into and ZFInt.outof — no Schröder–Bernstein, no
Classical.choice over a non-empty set of bijections. In particular, instEquivZFIntInt x is
deterministic in x.
Equations
- ZFSet.instEquivZFIntInt = { toFun := ZFSet.ZFInt.into, invFun := ZFSet.ZFInt.outof, left_inv := ZFSet.ZFInt.outof_into, right_inv := ZFSet.ZFInt.into_outof }
Instances For
Equations
Equations
The canonical equivalence preserves order: the strict order on {x // x ∈ Int} is exactly the
pullback of the strict order on ZFInt along instEquivZFIntInt.invFun = ZFInt.outof.
Euclidean division #
ZFInt is equipped with both common integer-division conventions, transported along the
canonical ring equivalence from ZFInt to ℤ.
The higher-priority Euclidean-domain instance makes / and % use Int.ediv and Int.emod; for
b ≠ 0, its remainder satisfies 0 ≤ a % b < |b|. Floor division remains available through the
explicitly named fdiv and fmod operations and through the lower-priority
floorEuclideanDomain instance.
The canonical ring equivalence between the quotient construction ZFInt and Lean's ℤ.
Equations
Instances For
The floor convention remains available as a lower-priority instance.
The ediv convention is the default convention used by / and %.
Explicit Euclidean division #
Euclidean quotient with a nonnegative remainder. This is also the operation used by /.
Equations
Instances For
Euclidean remainder in the interval [0, |b|) when b ≠ 0.
This is also the operation used by %.
Equations
Instances For
Explicit floor division #
Floor quotient: the quotient of a by b, rounded toward negative infinity.
Equations
- a.fdiv b = ZFSet.ZFInt.equivInt.symm ((ZFSet.ZFInt.equivInt a).fdiv (ZFSet.ZFInt.equivInt b))
Instances For
Floor remainder. For a nonzero divisor, it has the sign of the divisor.
Equations
- a.fmod b = ZFSet.ZFInt.equivInt.symm ((ZFSet.ZFInt.equivInt a).fmod (ZFSet.ZFInt.equivInt b))
Instances For
Transfer to ℤ #
equivInt is registered as a TransferEquiv, so that the transfer tactic reads a goal about
ZFInt in ℤ:
example (a b : ZFInt) : a + b = b + a := by
transfer ZFInt → ℤ =>
rw [Int.add_comm]
The ring operations, the numerals and the casts travel through the generic map_… lemmas of the
transfer_simps simp set; the order relations and the two division conventions are the lemmas
proved above, tagged here.
Equivalence used by the transfer tactic to move goals between ZFInt and ℤ.
Equations
Divisibility is read in ℤ; map_dvd_iff reads the wrong way round for transfer.