| 1 |
|
| 2 |
Set Implicit Arguments. |
| 3 |
|
| 4 |
Module NonPrim. |
| 5 |
Local Set Nonrecursive Elimination Schemes. |
| 6 |
Record prodwithlet (A B : Type) : Type := |
| 7 |
pair' { fst : A; fst' := fst; snd : B }. |
| 8 |
|
| 9 |
Definition letreclet (p : prodwithlet nat nat) := |
| 10 |
let (x, x', y) := p in x + y. |
| 11 |
|
| 12 |
Definition pletreclet (p : prodwithlet nat nat) := |
| 13 |
let 'pair' x x' y := p in x + y + x'. |
| 14 |
|
| 15 |
Definition pletreclet2 (p : prodwithlet nat nat) := |
| 16 |
let 'pair' x y := p in x + y. |
| 17 |
|
| 18 |
Check (pair 0 0). |
| 19 |
End NonPrim. |
| 20 |
|
| 21 |
Global Set Universe Polymorphism. |
| 22 |
Global Set Asymmetric Patterns. |
| 23 |
Local Set Nonrecursive Elimination Schemes. |
| 24 |
Local Set Primitive Projections. |
| 25 |
|
| 26 |
Record prod (A B : Type) : Type := |
| 27 |
pair { fst : A; snd : B }. |
| 28 |
|
| 29 |
Print prod_rect. |
| 30 |
|
| 31 |
(* What I really want: *) |
| 32 |
Definition prod_rect' A B (P : prod A B -> Type) (u : forall (fst : A) (snd : B), P (pair fst snd)) |
| 33 |
(p : prod A B) : P p |
| 34 |
:= u (fst p) (snd p). |
| 35 |
|
| 36 |
Definition conv : @prod_rect = @prod_rect'. |
| 37 |
Proof. reflexivity. Defined. |
| 38 |
|
| 39 |
Definition imposs := |
| 40 |
(fun A B P f (p : prod A B) => match p as p0 return P p0 with |
| 41 |
| {| fst := x ; snd := x0 |} => f x x0 |
| 42 |
end). |
| 43 |
|
| 44 |
Definition letrec (p : prod nat nat) := |
| 45 |
let (x, y) := p in x + y. |
| 46 |
Eval compute in letrec (pair 1 5). |
| 47 |
|
| 48 |
Goal forall p : prod nat nat, letrec p = fst p + snd p. |
| 49 |
Proof. |
| 50 |
reflexivity. |
| 51 |
Undo. |
| 52 |
intros p. |
| 53 |
case p. simpl. unfold letrec. simpl. reflexivity. |
| 54 |
Defined. |
| 55 |
|
| 56 |
Eval compute in conv. (* = eq_refl |
| 57 |
: prod_rect = prod_rect' *) |
| 58 |
|
| 59 |
Check eq_refl : @prod_rect = @prod_rect'. (* Toplevel input, characters 6-13: |
| 60 |
Error: |
| 61 |
The term "eq_refl" has type "prod_rect = prod_rect" |
| 62 |
while it is expected to have type "prod_rect = prod_rect'" |
| 63 |
(cannot unify "prod_rect" and "prod_rect'"). *) |
| 64 |
|
| 65 |
Record sigma (A : Type) (B : A -> Type) : Type := |
| 66 |
dpair { pi1 : A ; pi2 : B pi1 }. |