| 1 |
|
| 2 |
Axiom foo : forall (x y z t : nat), nat. |
| 3 |
|
| 4 |
Arguments foo {_} _ [z] t. |
| 5 |
Check (foo 1). |
| 6 |
Arguments foo {_} _ {z} {t}. |
| 7 |
Fail Arguments foo {_} _ [z] {t}. |
| 8 |
Check (foo 1). |
| 9 |
|
| 10 |
Definition foo1 [m] n := n + m. |
| 11 |
Check (foo1 1). |
| 12 |
|
| 13 |
Inductive vector {A : Type} : nat -> Type := |
| 14 |
| vnil : vector 0 |
| 15 |
| vcons : A -> forall {n'}, vector n' -> vector (S n'). |
| 16 |
|
| 17 |
Arguments vector A : clear implicits. |
| 18 |
|
| 19 |
Require Import TestSuite.jmeq. |
| 20 |
|
| 21 |
Definition head_subproof A n (v : vector A (S n)) (a : A) n' |
| 22 |
(v' : vector A n') (eqn : S n' = S n) (eqv : JMeq (vcons a v') v) := |
| 23 |
let H : S n = S n -> n' = n := |
| 24 |
match eqn in _ = n'' return n'' = S n -> n' = n with |
| 25 |
| eq_refl => |
| 26 |
fun eqSn' : S n' = S n => |
| 27 |
let eqn' : n' = n := |
| 28 |
f_equal (fun e => match e with 0 => n' | S n0 => n0 end) eqSn' in |
| 29 |
eq_ind_r (fun n'' => n'' = n) |
| 30 |
(eq_ind_r |
| 31 |
(fun n' => |
| 32 |
forall v', S n' = S n -> JMeq (vcons a v') v -> n = n) |
| 33 |
(fun (v' : vector A n) _ _ => eq_refl) eqn' v' |
| 34 |
eqn eqv) |
| 35 |
eqn' |
| 36 |
end in |
| 37 |
H eq_refl. |
| 38 |
|
| 39 |
Definition head {A : Type} {n : nat} (v : vector A (S n)) := |
| 40 |
let case_nil (eqn : O = S n) _ := |
| 41 |
False_rect (vector A n) |
| 42 |
(False_ind False |
| 43 |
(eq_ind O (fun e => match e with O => True | S _ => False end) |
| 44 |
I (S n) eqn)) in |
| 45 |
let case_cons (a : A) n' (v' : vector A n') |
| 46 |
(eqn : eq (S n') (S n)) (eqv : JMeq (vcons a v') v) := |
| 47 |
eq_rect n' (vector A) v' n |
| 48 |
(head_subproof A n v a n' v' eqn eqv) in |
| 49 |
match |
| 50 |
v as v' in vector _ n' return eq n' (S n) -> JMeq v' v -> vector A n |
| 51 |
with |
| 52 |
| vnil => case_nil |
| 53 |
| @vcons _ a n' v' => case_cons a n' v' |
| 54 |
end (eq_refl (S n)) (JMeq_refl v). |
| 55 |
|
| 56 |
Fixpoint app {A : Type} {n m : nat} (v : vector A n) (w : vector A m) : vector A (n + m) := |
| 57 |
match v in vector _ n return vector A (n + m) with |
| 58 |
| vnil => w |
| 59 |
| vcons a v' => vcons a (app v' w) |
| 60 |
end. |
| 61 |
|
| 62 |
(* Test sharing information between different hypotheses *) |
| 63 |
|
| 64 |
Parameters (a:_) (b:a=0). |
| 65 |
|
| 66 |
(* These examples were failing due to a lifting wrongly taking let-in into account *) |
| 67 |
|
| 68 |
Definition foo6 (x:=1) : forall {n:nat}, n=n := fun n => eq_refl. |
| 69 |
|
| 70 |
Fixpoint foo7 (x:=1) (n:nat) {p:nat} {struct n} : nat. |
| 71 |
Abort. |
| 72 |
|
| 73 |
(* Some example which should succeed with local implicit arguments *) |
| 74 |
|
| 75 |
Inductive A {P:forall m {n}, n=m -> Prop} := C : P 0 eq_refl -> A. |
| 76 |
Inductive B (P:forall m {n}, n=m -> Prop) := D : P 0 eq_refl -> B P. |
| 77 |
|
| 78 |
Inductive A' {P:forall m [n], n=m -> Prop} := C' : P 0 eq_refl -> A'. |
| 79 |
Inductive A'' [P:forall m {n}, n=m -> Prop] (b : bool):= C'' : P 0 eq_refl -> A'' b. |
| 80 |
Inductive A''' (P:forall m [n], n=m -> Prop) (b : bool):= C''' : P 0 eq_refl -> A''' P b. |
| 81 |
|
| 82 |
Definition F (id: forall [A] [x : A], A) := id. |
| 83 |
Definition G := let id := (fun [A] (x : A) => x) in id. |
| 84 |
Fail Definition G' := let id := (fun {A} (x : A) => x) in id. |