Definition IdApplicative : Applicative.
exists (fun A => A) (fun a (x : a) => x) (fun a b (f : a -> b) => f);
try reflexivity.
Defined.
Definition NatPlusApplicative : Applicative.
exists (fun _ => nat) (fun _ _ => 0) (fun a b => plus).
reflexivity.
intros _ _ _ x y z.
apply plus_assoc_reverse.
reflexivity.
intros _ _ x _.
apply plus_0_r.
Defined.
Definition ConstListApplicative (a : Type) : Applicative.
exists (fun _ => list a) (fun _ _ => nil) (fun _ _ => (@app a)).
reflexivity.
intros _ _ _ x y z.
apply app_assoc_reverse.
reflexivity.
intros _ _ x _.
apply app_nil_r.
Defined.
Definition KSpure i j a (x : a) : KleeneStore i j a :=
kleeneStore (fun v => x) (Vector.nil _).
Definition append_view A n p (P : Vector.t A (n + p) -> Type) :
(forall v1 v2, P (Vector.append v1 v2)) ->
forall v, P v.
induction n.
intros f v.
apply (f (Vector.nil _)).
intros f v.
replace v with (Vector.cons _ (Vector.hd v) (n + p) (Vector.tl v)).
destruct (Vector.tl v) as [v1 v2] using IHn.
apply (f (Vector.cons _ (Vector.hd v) _ v1)).
assert (forall m (v : Vector.t A (S m)), Vector.cons A (Vector.hd v) m (Vector.tl v) = v).
clear -A.
apply Vector.caseS.
reflexivity.
apply H.
Defined.

Lemma append_view_append A n p (P : Vector.t A (n + p) -> Type) f v1 v2 :
append_view (P:=P) f (Vector.append v1 v2) = f v1 v2.