Section Fin.
Global Coercion fin_to_nat (n : nat) (i : Fin.t n) : nat := proj1_sig (Fin.to_nat i).
Global Set Printing Coercions.
Fixpoint finMax (n : nat) {struct n} : n <> 0 -> Fin.t n.
(* Arguments finMax (n) H : clear implicits. *)
(* Compute finMax (ltac:(congruence) : 1 <> 0). *)
(* Compute finMax (ltac:(congruence) : 10 <> 0). *)
(* Compute finMax' 99. *)
Definition finMin (n : nat) : n <> 0 -> Fin.t n.
Definition finMin_opt (n : nat) : option (Fin.t n).
End Fin.
Fixpoint map_vect_list (X Y : Type) (f : X -> Y -> X) (n : nat) (vs : Vector.t Y n) (ls : list X) {struct ls} : list X :=
match ls with
| nil => nil
| x :: ls' =>
match vs with
| [| |] => ls
| y ::: vs' =>
f x y :: map_vect_list f vs' ls'
end
end.
Definition insertKnownSymbol {n : nat} (readSymbols : Vector.t (option sig) n) (i : Fin.t n) (s : option sig) : Vector.t (option sig) n :=
Vector.replace readSymbols i s.
Fixpoint insertKnownSymbols {n : nat} (readSymbols : Vector.t (option sig) n) (i : Fin.t n) (newSymbols : list (option sig)) :
Vector.t (option sig) n :=
match newSymbols with
| nil => readSymbols
| s :: newSymbols' =>
match finSucc_opt i with
| Some i' => insertKnownSymbols (insertKnownSymbol readSymbols i s) i' newSymbols'
| None => insertKnownSymbol readSymbols i s
end
end.
(* H : knowsFirstSymbols (insertKnownSymbols (current tp ::: Vector.const None n) Fin0 (map (current (sig:=sig)) (tp :: vector_to_list T))) ([] ++ tp :: vector_to_list T) ============================ insertKnownSymbols (current tp ::: Vector.const None n) Fin0 (vector_to_list (current_chars T)) = current_chars (tp ::: T) *)

Lemma insertKnownSymbols_correct_cons n (T : tapes sig (S n)) (min minSucc : Fin.t (S n)) :
fin_to_nat min = 0 ->
fin_to_nat minSucc = 1 ->
insertKnownSymbols (insertKnownSymbol (Vector.const None (S n)) min (current (Vector.hd T))) minSucc
(map (@current _) (vector_to_list (Vector.tl T))) =
current_chars T.