~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to contrib/setoid_ring/BinList.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(************************************************************************)
 
2
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
 
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
 
4
(*   \VV/  **************************************************************)
 
5
(*    //   *      This file is distributed under the terms of the       *)
 
6
(*         *       GNU Lesser General Public License Version 2.1        *)
 
7
(************************************************************************)
 
8
 
 
9
Set Implicit Arguments.
 
10
Require Import BinPos.
 
11
Require Export List.
 
12
Require Export ListTactics.
 
13
Open Local Scope positive_scope.
 
14
 
 
15
Section MakeBinList.
 
16
 Variable A : Type.
 
17
 Variable default : A.
 
18
 
 
19
 Fixpoint jump (p:positive) (l:list A) {struct p} : list A :=
 
20
  match p with
 
21
  | xH => tail l
 
22
  | xO p => jump p (jump p l)
 
23
  | xI p  => jump p (jump p (tail l))
 
24
  end.
 
25
 
 
26
 Fixpoint nth (p:positive) (l:list A) {struct p} : A:=
 
27
  match p with
 
28
  | xH => hd default l
 
29
  | xO p => nth p (jump p l)
 
30
  | xI p => nth p (jump p (tail l))
 
31
  end. 
 
32
 
 
33
 Lemma jump_tl : forall j l, tail (jump j l) = jump j (tail l).
 
34
 Proof. 
 
35
  induction j;simpl;intros.
 
36
  repeat rewrite IHj;trivial.
 
37
  repeat rewrite IHj;trivial.
 
38
  trivial.
 
39
 Qed.
 
40
 
 
41
 Lemma jump_Psucc : forall j l, 
 
42
  (jump (Psucc j) l) = (jump 1 (jump j l)).
 
43
 Proof.
 
44
  induction j;simpl;intros.
 
45
  repeat rewrite IHj;simpl;repeat rewrite jump_tl;trivial.
 
46
  repeat rewrite jump_tl;trivial.
 
47
  trivial.
 
48
 Qed.
 
49
 
 
50
 Lemma jump_Pplus : forall i j l, 
 
51
  (jump (i + j) l) = (jump i (jump j l)).
 
52
 Proof.
 
53
  induction i;intros.
 
54
  rewrite xI_succ_xO;rewrite Pplus_one_succ_r.
 
55
  rewrite <- Pplus_diag;repeat rewrite <- Pplus_assoc.
 
56
  repeat rewrite IHi.
 
57
  rewrite Pplus_comm;rewrite <- Pplus_one_succ_r;rewrite jump_Psucc;trivial.
 
58
  rewrite <- Pplus_diag;repeat rewrite <- Pplus_assoc.
 
59
  repeat rewrite IHi;trivial.
 
60
  rewrite Pplus_comm;rewrite <- Pplus_one_succ_r;rewrite jump_Psucc;trivial.
 
61
 Qed.
 
62
 
 
63
 Lemma jump_Pdouble_minus_one : forall i l,
 
64
  (jump (Pdouble_minus_one i) (tail l)) = (jump i (jump i l)).
 
65
 Proof.
 
66
  induction i;intros;simpl.
 
67
  repeat rewrite jump_tl;trivial.
 
68
  rewrite IHi. do 2 rewrite <- jump_tl;rewrite IHi;trivial.
 
69
  trivial.
 
70
 Qed.
 
71
 
 
72
 
 
73
 Lemma nth_jump : forall p l, nth p (tail l) = hd default (jump p l).
 
74
 Proof.
 
75
  induction p;simpl;intros.
 
76
  rewrite <-jump_tl;rewrite IHp;trivial.
 
77
  rewrite <-jump_tl;rewrite IHp;trivial.
 
78
  trivial.
 
79
 Qed.
 
80
 
 
81
 Lemma nth_Pdouble_minus_one :
 
82
  forall p l, nth (Pdouble_minus_one p) (tail l) = nth p (jump p l).
 
83
 Proof.
 
84
  induction p;simpl;intros.
 
85
  repeat rewrite jump_tl;trivial.
 
86
  rewrite jump_Pdouble_minus_one.
 
87
  repeat rewrite <- jump_tl;rewrite IHp;trivial.
 
88
  trivial.
 
89
 Qed.
 
90
 
 
91
End MakeBinList.
 
92
 
 
93