Section test.
Variable P : Prop.
Variable dec_P : dec P.
Goal if Dec (1 = 1) then True else False.
Goal P -> if (Dec P) then True else False.
Goal ~ P -> if (Dec P) then False else True.
Goal P -> (if (Dec P) then False else True) -> False.
Goal ~ P -> (if (Dec P) then True else False) -> False.
End test.
Ltac inv_pair :=
once lazymatch goal with
| [ H : (_, _) = (_, _) |- _] => inv H
| [ |- (_, _) = (_, _) ] => f_equal
end.
Ltac destruct_param_tape_pair :=
once lazymatch goal with
| [ x : _ * tapes _ _ |- _] =>
let ymid := fresh "ymid" in
let tmid := fresh "tmid" in
destruct x as (ymid&tmid)
end.
Ltac destruct_unit :=
repeat once lazymatch goal with
| [ x : unit |- _ ] => destruct x
end.
(* Rewrite [eq]-assumptions, but only in the goal. This is much faster than [TMSimp]. *)
Ltac TMSimp_goal :=
repeat multimatch goal with
| [ H : ?X = _ |- _ ] => rewrite H
end.
Fixpoint all_vec {X:Type} {n:nat}  {struct n}: (Vector.t X n -> Prop) -> Prop :=
match n with
0 => fun A => A (@Vector.nil _)
| S n => fun A => forall x, all_vec (fun xs => A (x:::xs))
end.
Tactic Notation "vector_destruct" hyp(tin) :=
let rec introT n :=
once lazymatch n with
|  S ?n =>
let x := fresh tin "_0" in
intro x;introT n
| 0 => try clear tin
| _ => simple apply all_vec_correct2;try clear tin;let tin' := fresh tin in intros tin'
end
in
let tac n :=  revert dependent tin; refine (all_vec_correct _);
cbn [all_vec];introT n;cbn [Vector.nth Vector.caseS];intros
in
once lazymatch type of tin with
tapes _ ?n => tac n
| Vector.t _ ?n => tac n
end.

Lemma eq_nth_iff' X n (v w : Vector.t X n):
(forall i : Fin.t n, v[@i] = w[@i]) -> v = w.