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

« back to all changes in this revision

Viewing changes to test-suite/success/Fixpoint.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
(* Playing with (co-)fixpoints with local definitions *)
 
2
 
 
3
Inductive listn : nat -> Set :=
 
4
  niln : listn 0
 
5
| consn : forall n:nat, nat -> listn n -> listn (S n).
 
6
 
 
7
Fixpoint f (n:nat) (m:=pred n) (l:listn m) (p:=S n) {struct l} : nat :=
 
8
   match n with O => p | _ => 
 
9
     match l with niln => p | consn q _ l => f (S q) l end
 
10
   end.
 
11
 
 
12
Eval compute in (f 2 (consn 0 0 niln)).
 
13
 
 
14
CoInductive Stream : nat -> Set :=
 
15
  Consn : forall n, nat -> Stream n -> Stream (S n).
 
16
 
 
17
CoFixpoint g (n:nat) (m:=pred n) (l:Stream m) (p:=S n) : Stream p :=
 
18
    match n return (let m:=pred n in forall l:Stream m, let p:=S n in Stream p)
 
19
    with
 
20
    | O => fun l:Stream 0 => Consn O 0 l
 
21
    | S n' =>
 
22
      fun l:Stream n' =>
 
23
      let l' :=
 
24
        match l in Stream q return Stream (pred q) with Consn _ _ l => l end
 
25
      in
 
26
      let a := match l with Consn _ a l => a end in
 
27
      Consn (S n') (S a) (g n' l')
 
28
   end l.
 
29
 
 
30
Eval compute in (fun l => match g 2 (Consn 0 6 l) with Consn _ a _ => a end).
 
31
 
 
32
(* Check inference of simple types in presence of non ambiguous
 
33
   dependencies (needs revision 10125) *)
 
34
 
 
35
Section folding.
 
36
 
 
37
Inductive vector (A:Type) : nat -> Type :=
 
38
  | Vnil : vector A 0
 
39
  | Vcons : forall (a:A) (n:nat), vector A n -> vector A (S n).
 
40
 
 
41
Variables (B C : Set) (g : B -> C -> C) (c : C).
 
42
 
 
43
Fixpoint foldrn n bs :=
 
44
  match bs with
 
45
  | Vnil => c
 
46
  | Vcons b _ tl => g b (foldrn _ tl)
 
47
  end.
 
48
 
 
49
End folding.
 
50