Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
Properties of addition.
This file is mostly OBSOLETE now, see module PeanoNat.Nat instead.
Nat.add is defined in Init/Nat.v as:
Fixpoint add (n m:nat) : nat := match n with | O => m | S p => S (p + m) end where "n + m" := (add n m) : nat_scope.
Require Import PeanoNat. Local Open Scope nat_scope.
Notation plus_0_l := Nat.add_0_l (only parsing). Notation plus_0_r := Nat.add_0_r (only parsing). Notation plus_comm := Nat.add_comm (only parsing). Notation plus_assoc := Nat.add_assoc (only parsing). Notation plus_permute := Nat.add_shuffle3 (only parsing). Definition plus_Snm_nSm : forall n m, S n + m = n + S m := Peano.plus_n_Sm.n, m, p:natn + m + p = n + (m + p)n, m, p:natn + m + p = n + (m + p)apply Nat.add_assoc. Qed.n, m, p:natn + (m + p) = n + m + p
n, m, p:natp + n = p + m -> n = mapply Nat.add_cancel_l. Qed.n, m, p:natp + n = p + m -> n = mn, m, p:natp + n <= p + m -> n <= mapply Nat.add_le_mono_l. Qed.n, m, p:natp + n <= p + m -> n <= mn, m, p:natp + n < p + m -> n < mapply Nat.add_lt_mono_l. Qed.n, m, p:natp + n < p + m -> n < m
n, m, p:natn <= m -> p + n <= p + mapply Nat.add_le_mono_l. Qed.n, m, p:natn <= m -> p + n <= p + mn, m, p:natn <= m -> n + p <= m + papply Nat.add_le_mono_r. Qed.n, m, p:natn <= m -> n + p <= m + pn, m, p:natn < m -> p + n < p + mapply Nat.add_lt_mono_l. Qed.n, m, p:natn < m -> p + n < p + mn, m, p:natn < m -> n + p < m + papply Nat.add_lt_mono_r. Qed.n, m, p:natn < m -> n + p < m + pn, m, p, q:natn <= m -> p <= q -> n + p <= m + qapply Nat.add_le_mono. Qed.n, m, p, q:natn <= m -> p <= q -> n + p <= m + qn, m, p, q:natn <= m -> p < q -> n + p < m + qapply Nat.add_le_lt_mono. Qed.n, m, p, q:natn <= m -> p < q -> n + p < m + qn, m, p, q:natn < m -> p <= q -> n + p < m + qapply Nat.add_lt_le_mono. Qed.n, m, p, q:natn < m -> p <= q -> n + p < m + qn, m, p, q:natn < m -> p < q -> n + p < m + qapply Nat.add_lt_mono. Qed.n, m, p, q:natn < m -> p < q -> n + p < m + qn, m:natn <= n + mapply Nat.le_add_r. Qed.n, m:natn <= n + mn, m:natm <= n + mn, m:natm <= n + mapply Nat.le_add_r. Qed.n, m:natm <= m + nn, m, p:natn <= m -> n <= m + pn, m, p:natn <= m -> n <= m + pnow rewrite <- Nat.le_add_r. Qed.n, m, p:natH:n <= mn <= m + pn, m, p:natn < m -> n < m + pn, m, p:natn < m -> n < m + pn, m, p:natH:n < mn < m + pn, m, p:natH:n < mn < mn, m, p:natH:n < mm <= m + papply Nat.le_add_r. Qed.n, m, p:natH:n < mm <= m + p
n, m:natn + m = 0 -> n = 0 /\ m = 0destruct n; now split. Qed.n, m:natn + m = 0 -> n = 0 /\ m = 0m, n:natm + n = 1 -> {m = 0 /\ n = 1} + {m = 1 /\ n = 0}m, n:natm + n = 1 -> {m = 0 /\ n = 1} + {m = 1 /\ n = 0}m, n:natS m + n = 1 -> {S m = 0 /\ n = 1} + {S m = 1 /\ n = 0}discriminate. Defined.m, n:natS (S m) + n = 1 -> {S (S m) = 0 /\ n = 1} + {S (S m) = 1 /\ n = 0}
Notation plus_permute_2_in_4 := Nat.add_shuffle1 (only parsing).
tail_plus is an alternative definition for plus which is
tail-recursive, whereas plus is not. This can be useful
when extracting programs.
Fixpoint tail_plus n m : nat := match n with | O => m | S n => tail_plus n (S m) end.forall n m : nat, n + m = tail_plus n mforall n m : nat, n + m = tail_plus n mintro m; rewrite <- IHn; simpl; auto. Qed.n:natIHn:forall m : nat, n + m = tail_plus n mforall m : nat, S (n + m) = tail_plus n (S m)
n, m:natn <> S (m + n)apply Nat.succ_add_discr. Qed.n, m:natn <> S (m + n)Proof (succ_plus_discr n 1).n:natn <> S (S n)Proof (succ_plus_discr n 2).n:natn <> S (S (S n))Proof (succ_plus_discr n 3).n:natn <> S (S (S (S n)))
Hint Immediate plus_comm : arith. Hint Resolve plus_assoc plus_assoc_reverse : arith. Hint Resolve plus_le_compat_l plus_le_compat_r : arith. Hint Resolve le_plus_l le_plus_r le_plus_trans : arith. Hint Immediate lt_plus_trans : arith. Hint Resolve plus_lt_compat_l plus_lt_compat_r : arith.
For compatibility, we "Require" the same files as before
Require Import Le Lt.