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) *) (************************************************************************) Require Import PeanoNat. Local Open Scope nat_scope.
Equality on natural numbers
Fixpoint eq_nat n m : Prop := match n, m with | O, O => True | O, S _ => False | S _, O => False | S n1, S m1 => eq_nat n1 m1 end.n:nateq_nat n ninduction n; simpl; auto. Qed. Hint Resolve eq_nat_refl: arith.n:nateq_nat n n
eq restricted to nat and eq_nat are equivalent
n, m:nateq_nat n m <-> n = mn, m:nateq_nat n m <-> n = mn, m:nateq_nat n m -> n = mn, m:natn = m -> eq_nat n mrevert m; induction n; destruct m; simpl; contradiction || auto.n, m:nateq_nat n m -> n = mintros <-; apply eq_nat_refl. Qed.n, m:natn = m -> eq_nat n mn, m:natn = m -> eq_nat n mapply eq_nat_is_eq. Qed.n, m:natn = m -> eq_nat n mn, m:nateq_nat n m -> n = mapply eq_nat_is_eq. Qed. Hint Immediate eq_eq_nat eq_nat_eq: arith.n, m:nateq_nat n m -> n = mforall (n : nat) (P : nat -> Prop), P n -> forall m : nat, eq_nat n m -> P mintros; replace m with n; auto with arith. Qed.forall (n : nat) (P : nat -> Prop), P n -> forall m : nat, eq_nat n m -> P mforall n m : nat, {eq_nat n m} + {~ eq_nat n m}forall n m : nat, {eq_nat n m} + {~ eq_nat n m}{True} + {~ True}m:nat{False} + {~ False}n:natIHn:forall m : nat, {eq_nat n m} + {~ eq_nat n m}{False} + {~ False}n:natIHn:forall m0 : nat, {eq_nat n m0} + {~ eq_nat n m0}m:nat{eq_nat n m} + {~ eq_nat n m}left; trivial.{True} + {~ True}right; intro; trivial.m:nat{False} + {~ False}right; intro; trivial.n:natIHn:forall m : nat, {eq_nat n m} + {~ eq_nat n m}{False} + {~ False}apply IHn. Defined.n:natIHn:forall m0 : nat, {eq_nat n m0} + {~ eq_nat n m0}m:nat{eq_nat n m} + {~ eq_nat n m}
Boolean equality on nat.
Notation beq_nat := Nat.eqb (only parsing). Notation beq_nat_true_iff := Nat.eqb_eq (only parsing). Notation beq_nat_false_iff := Nat.eqb_neq (only parsing).n:nattrue = (n =? n)n:nattrue = (n =? n)apply Nat.eqb_refl. Qed.n:nat(n =? n) = truen, m:nat(n =? m) = true -> n = mapply Nat.eqb_eq. Qed.n, m:nat(n =? m) = true -> n = mn, m:nat(n =? m) = false -> n <> mapply Nat.eqb_neq. Qed.n, m:nat(n =? m) = false -> n <> m
TODO: is it really useful here to have a Defined ?
Otherwise we could use Nat.eqb_eq
forall n m : nat, true = (n =? m) -> n = mforall n m : nat, true = (n =? m) -> n = mtrue = true -> 0 = 0m:nattrue = false -> 0 = S mn:natIHn:forall m : nat, true = (n =? m) -> n = mtrue = false -> S n = 0n:natIHn:forall m0 : nat, true = (n =? m0) -> n = m0m:nattrue = (n =? m) -> S n = S mreflexivity.true = true -> 0 = 0discriminate.m:nattrue = false -> 0 = S mdiscriminate.n:natIHn:forall m : nat, true = (n =? m) -> n = mtrue = false -> S n = 0n:natIHn:forall m0 : nat, true = (n =? m0) -> n = m0m:nattrue = (n =? m) -> S n = S mn:natIHn:forall m0 : nat, true = (n =? m0) -> n = m0m:natH:true = (n =? m)S n = S mreflexivity. Defined.n:natIHn:forall m0 : nat, true = (n =? m0) -> n = m0m:natH:true = (n =? m)S n = S n