data.nat.dist

# Distance function on ℕ #

This file defines a simple distance function on naturals from truncated substraction.

def nat.dist (n m : ) :

Distance (absolute value of difference) between natural numbers.

Equations
theorem nat.dist.def (n m : ) :
n.dist m = n - m + (m - n)
theorem nat.dist_comm (n m : ) :
n.dist m = m.dist n
@[simp]
theorem nat.dist_self (n : ) :
n.dist n = 0
theorem nat.eq_of_dist_eq_zero {n m : } (h : n.dist m = 0) :
n = m
theorem nat.dist_eq_zero {n m : } (h : n = m) :
n.dist m = 0
theorem nat.dist_eq_sub_of_le {n m : } (h : n m) :
n.dist m = m - n
theorem nat.dist_eq_sub_of_le_right {n m : } (h : m n) :
n.dist m = n - m
theorem nat.dist_tri_left (n m : ) :
m n.dist m + n
theorem nat.dist_tri_right (n m : ) :
m n + n.dist m
theorem nat.dist_tri_left' (n m : ) :
n n.dist m + m
theorem nat.dist_tri_right' (n m : ) :
n m + n.dist m
theorem nat.dist_zero_right (n : ) :
n.dist 0 = n
theorem nat.dist_zero_left (n : ) :
0.dist n = n
theorem nat.dist_add_add_right (n k m : ) :
(n + k).dist (m + k) = n.dist m
theorem nat.dist_add_add_left (k n m : ) :
(k + n).dist (k + m) = n.dist m
theorem nat.dist_eq_intro {n m k l : } (h : n + m = k + l) :
n.dist k = l.dist m
theorem nat.dist.triangle_inequality (n m k : ) :
n.dist k n.dist m + m.dist k
theorem nat.dist_mul_right (n k m : ) :
(n * k).dist (m * k) = n.dist m * k
theorem nat.dist_mul_left (k n m : ) :
(k * n).dist (k * m) = k * n.dist m
theorem nat.dist_succ_succ {i j : } :
i.succ.dist j.succ = i.dist j
theorem nat.dist_pos_of_ne {i j : } :
i j0 < i.dist j