lean4-htt/library/data/nat/sub.lean

24 lines
759 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2014 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Jeremy Avigad
Subtraction on the natural numbers, as well as min, max, and distance.
-/
namespace nat
/- subtraction -/
theorem succ_sub_succ : Π (n m : ), succ n - succ m = n - m
| n 0 := rfl
| n (succ m) := congr_arg pred (succ_sub_succ n m)
protected theorem sub_add_cancel : Π{n i : }, i ≤ n → (n - i) + i = n
| n 0 p := rfl
| (succ n) (succ i) p :=
calc (succ n - succ i) + succ i
= ((n - i) + succ i) : congr_arg (λ v, v + succ i) (succ_sub_succ n i)
... = succ n : congr_arg succ (sub_add_cancel (pred_le_pred p))
end nat