lemma
L31 ↗val_sub_cases
AlgebraicCurves.Foundations.Algebra.Proofs.ZMod_chordMatrix_transpose_eq_neg.SolChord.val_sub_cases
Source context 4 commands
Surrounding namespaces, section variables, and local commands at this declaration.
section ProofImplementation
namespace AlgebraicCurves.Foundations.Algebra.Proofs.ZMod_chordMatrix_transpose_eq_neg
namespace SolChord
variable {N : ℕ} [NeZero N]Lean source · full declaration
lemma val_sub_cases {a b : ZMod N} (hab : a ≠ b) :
(a - b).val = if b.val ≤ a.val then a.val - b.val else N + a.val - b.val := by
rcases le_or_gt b.val a.val with h | h
· simp only [h, ite_true, ZMod.val_sub h]
· simp only [not_le.mpr h, ite_false]
have hba : b - a ≠ 0 := sub_ne_zero.mpr (Ne.symm hab)
have hrw : a - b = -(b - a) := by ring
rw [hrw, ZMod.neg_val, ite_eq_right hba, ZMod.val_sub (le_of_lt h)]
have hal : a.val < N := ZMod.val_lt _
omega