coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: AUGER Cedric <Cedric.Auger AT lri.fr>
- Cc: Coq-Club Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Init/Peano.v
- Date: Thu, 19 May 2011 11:38:19 +0200
Le Thu, 19 May 2011 06:26:18 -0400,
Vladimir Voevodsky
<vladimir AT ias.edu>
a écrit :
> Hello,
>
> where can I find the source (.v file ) for the basic library e.g.
> Init/Peano.v ? It does not appear to be in the usual sources.
>
> V.
Strange, I have it in "($COQ)/theories/Init/Peano.v"
Maybe we don't have the same version. (I use an old trunk version of
the 8.3, but I guess it didn't changed since)
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) (** The type [nat] of Peano natural numbers (built from [O] and [S]) is defined in [Datatypes.v] *) (** This module defines the following operations on natural numbers : - predecessor [pred] - addition [plus] - multiplication [mult] - less or equal order [le] - less [lt] - greater or equal [ge] - greater [gt] It states various lemmas and theorems about natural numbers, including Peano's axioms of arithmetic (in Coq, these are provable). Case analysis on [nat] and induction on [nat * nat] are provided too *) Require Import Notations. Require Import Datatypes. Require Import Logic. Unset Boxed Definitions. Open Scope nat_scope. Definition eq_S := f_equal S. Hint Resolve (f_equal S): v62. Hint Resolve (f_equal (A:=nat)): core. (** The predecessor function *) Definition pred (n:nat) : nat := match n with | O => n | S u => u end. Hint Resolve (f_equal pred): v62. Theorem pred_Sn : forall n:nat, n = pred (S n). Proof. simpl; reflexivity. Qed. (** Injectivity of successor *) Definition eq_add_S n m (H: S n = S m): n = m := f_equal pred H. Hint Immediate eq_add_S: core. Theorem not_eq_S : forall n m:nat, n <> m -> S n <> S m. Proof. red in |- *; auto. Qed. Hint Resolve not_eq_S: core. Definition IsSucc (n:nat) : Prop := match n with | O => False | S p => True end. (** Zero is not the successor of a number *) Theorem O_S : forall n:nat, 0 <> S n. Proof. discriminate. Qed. Hint Resolve O_S: core. Theorem n_Sn : forall n:nat, n <> S n. Proof. induction n; auto. Qed. Hint Resolve n_Sn: core. (** Addition *) Fixpoint plus (n m:nat) : nat := match n with | O => m | S p => S (p + m) end where "n + m" := (plus n m) : nat_scope. Hint Resolve (f_equal2 plus): v62. Hint Resolve (f_equal2 (A1:=nat) (A2:=nat)): core. Lemma plus_n_O : forall n:nat, n = n + 0. Proof. induction n; simpl in |- *; auto. Qed. Hint Resolve plus_n_O: core. Lemma plus_O_n : forall n:nat, 0 + n = n. Proof. auto. Qed. Lemma plus_n_Sm : forall n m:nat, S (n + m) = n + S m. Proof. intros n m; induction n; simpl in |- *; auto. Qed. Hint Resolve plus_n_Sm: core. Lemma plus_Sn_m : forall n m:nat, S n + m = S (n + m). Proof. auto. Qed. (** Standard associated names *) Notation plus_0_r_reverse := plus_n_O (only parsing). Notation plus_succ_r_reverse := plus_n_Sm (only parsing). (** Multiplication *) Fixpoint mult (n m:nat) : nat := match n with | O => 0 | S p => m + p * m end where "n * m" := (mult n m) : nat_scope. Hint Resolve (f_equal2 mult): core. Lemma mult_n_O : forall n:nat, 0 = n * 0. Proof. induction n; simpl in |- *; auto. Qed. Hint Resolve mult_n_O: core. Lemma mult_n_Sm : forall n m:nat, n * m + n = n * S m. Proof. intros; induction n as [| p H]; simpl in |- *; auto. destruct H; rewrite <- plus_n_Sm; apply (f_equal S). pattern m at 1 3 in |- *; elim m; simpl in |- *; auto. Qed. Hint Resolve mult_n_Sm: core. (** Standard associated names *) Notation mult_0_r_reverse := mult_n_O (only parsing). Notation mult_succ_r_reverse := mult_n_Sm (only parsing). (** Truncated subtraction: [m-n] is [0] if [n>=m] *) Fixpoint minus (n m:nat) : nat := match n, m with | O, _ => n | S k, O => n | S k, S l => k - l end where "n - m" := (minus n m) : nat_scope. (** Definition of the usual orders, the basic properties of [le] and [lt] can be found in files Le and Lt *) Inductive le (n:nat) : nat -> Prop := | le_n : n <= n | le_S : forall m:nat, n <= m -> n <= S m where "n <= m" := (le n m) : nat_scope. Hint Constructors le: core. (*i equivalent to : "Hints Resolve le_n le_S : core." i*) Definition lt (n m:nat) := S n <= m. Hint Unfold lt: core. Infix "<" := lt : nat_scope. Definition ge (n m:nat) := m <= n. Hint Unfold ge: core. Infix ">=" := ge : nat_scope. Definition gt (n m:nat) := m < n. Hint Unfold gt: core. Infix ">" := gt : nat_scope. Notation "x <= y <= z" := (x <= y /\ y <= z) : nat_scope. Notation "x <= y < z" := (x <= y /\ y < z) : nat_scope. Notation "x < y < z" := (x < y /\ y < z) : nat_scope. Notation "x < y <= z" := (x < y /\ y <= z) : nat_scope. Theorem le_pred : forall n m, n <= m -> pred n <= pred m. Proof. induction 1; auto. destruct m; simpl; auto. Qed. Theorem le_S_n : forall n m, S n <= S m -> n <= m. Proof. intros n m. exact (le_pred (S n) (S m)). Qed. (** Case analysis *) Theorem nat_case : forall (n:nat) (P:nat -> Prop), P 0 -> (forall m:nat, P (S m)) -> P n. Proof. induction n; auto. Qed. (** Principle of double induction *) Theorem nat_double_ind : forall R:nat -> nat -> Prop, (forall n:nat, R 0 n) -> (forall n:nat, R (S n) 0) -> (forall n m:nat, R n m -> R (S n) (S m)) -> forall n m:nat, R n m. Proof. induction n; auto. destruct m as [| n0]; auto. Qed. (** Maximum and minimum : definitions and specifications *) Fixpoint max n m : nat := match n, m with | O, _ => m | S n', O => n | S n', S m' => S (max n' m') end. Fixpoint min n m : nat := match n, m with | O, _ => 0 | S n', O => 0 | S n', S m' => S (min n' m') end. Theorem max_l : forall n m : nat, m <= n -> max n m = n. Proof. induction n; destruct m; simpl; auto. inversion 1. intros. apply f_equal. apply IHn. apply le_S_n. trivial. Qed. Theorem max_r : forall n m : nat, n <= m -> max n m = m. Proof. induction n; destruct m; simpl; auto. inversion 1. intros. apply f_equal. apply IHn. apply le_S_n. trivial. Qed. Theorem min_l : forall n m : nat, n <= m -> min n m = n. Proof. induction n; destruct m; simpl; auto. inversion 1. intros. apply f_equal. apply IHn. apply le_S_n. trivial. Qed. Theorem min_r : forall n m : nat, m <= n -> min n m = m. Proof. induction n; destruct m; simpl; auto. inversion 1. intros. apply f_equal. apply IHn. apply le_S_n. trivial. Qed.
- Re: [Coq-Club] an update to "Univalent Foundations", Robin Green
- Re: [Coq-Club] an update to "Univalent Foundations",
Vladimir Voevodsky
- [Coq-Club] Init/Peano.v,
Vladimir Voevodsky
- Re: [Coq-Club] Init/Peano.v, AUGER Cedric
- Re: [Coq-Club] Init/Peano.v, Vladimir Voevodsky
- Re: [Coq-Club] Init/Peano.v,
Tom Prince
- Re: [Coq-Club] Init/Peano.v, Vladimir Voevodsky
- [Coq-Club] Init/Peano.v,
Vladimir Voevodsky
- <Possible follow-ups>
- Re: [Coq-Club] an update to "Univalent Foundations",
Bruno Barras
- Re: [Coq-Club] an update to "Univalent Foundations",
Tom Prince
- Re: [Coq-Club] an update to "Univalent Foundations", Vladimir Voevodsky
- Re: [Coq-Club] an update to "Univalent Foundations",
Tom Prince
- Re: [Coq-Club] an update to "Univalent Foundations",
Vladimir Voevodsky
Archive powered by MhonArc 2.6.16.