/-
Copyright (c) 2026 Terence Rokop. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Terence Rokop
-/modulepublicimportMathlib.Data.Nat.Notation
Choice-free division, remainder and pairing on Fin
Batteries' Fin.divNat proves its bound through
Nat.div_lt_of_lt_mul, which depends on Classical.choice. The
three operations here are choice-free counterparts of Fin.divNat,
Fin.modNat and Fin.mkDivMod, together with the round trips
exhibiting them as a bijection Fin m × Fin n ≃ Fin (m * n).
Main definitions
Fin.divNatC, Fin.modNatC — the quotient and remainder of an
index of Fin (m * n).
Fin.pairC — the index of Fin (m * n) with given quotient and
remainder, the counterpart of Fin.mkDivMod.
Main statements
Fin.divNatC_pairC, Fin.modNatC_pairC,
Fin.pairC_divNatC_modNatC — the three round trips.
Implementation notes
Fin.modNat and Fin.mkDivMod depend on no axiom outside propext,
so Fin.modNatC and Fin.pairC are present for uniformity rather
than necessity. Both round trips stated over Fin.divNat inherit its
dependence on Classical.choice, so a family mixing the Batteries
declarations in would still rebuild two of the three round trips;
the three here are stated over one pairing throughout. Fin.pairC a b is
a * n + b where Fin.mkDivMod a b is n * a + b, the same pairing
with the multiplication commuted.
Nat's division and order API interleaves choice-dependent lemmas
with choice-free ones under no separating convention of name or
namespace: Nat.div_lt_of_lt_mul and Nat.lt_of_mul_lt_mul_left
depend on Classical.choice while Nat.div_mul_le_self,
Nat.add_mul_div_right and Nat.div_add_mod' do not. The bound
proofs below therefore route through omega over hypotheses named
individually, or through case analysis on Nat.lt_or_ge, rather than
through whichever lemma states the bound directly.
The upstream target of this module is Batteries rather than mathlib4,
the declarations it replaces being Batteries declarations; where such
content belongs is TODO.md § Upstream destination of core- and
Batteries-targeted content.
Tags
fin, division, remainder, pairing, choice-free
@[expose]publicsectionnamespaceFin
The quotient of an index of Fin (m * n) by n, choice-free
(unlike Fin.divNat).