(** * Some properties of [cond] *)

(* Specifications: *)
Lemma cond_simpl_nil n s fn fc ff ft l1 l2 :
sem fc l1 l2 = nil ->
sem (comp n s cond nil [fc; fn; ft; ff]) l1 l2 = sem fn l1 l2.
Lemma cond_simpl_notnil n s fn fc ft ff l1 l2 :
sem fc l1 l2 <> nil ->
sem (comp n s cond nil [fc; fn; ft; ff]) l1 l2 =
match sem fc l1 l2 with
| nil => nil
| true :: _ => sem ft l1 l2
| false :: _ => sem ff l1 l2
end.
Lemma cond_simpl_true n s fn fc ff ft l1 l2 :
hd false (sem fc l1 l2) = true ->
sem (comp n s cond nil [fc; fn; ft; ff]) l1 l2 = sem ft l1 l2.
Lemma cond_simpl_false n s fn fc ff ft l1 l2 l :
sem fc l1 l2 = false :: l ->
sem (comp n s cond nil [fc; fn; ft; ff]) l1 l2 = sem ff l1 l2.
Lemma sem_nth :
forall i start len f d vnl vsl,
0 <= i < len ->
sem (nth i (map f (seq start len)) d) vnl vsl = sem (f (i+start)) vnl vsl.
Lemma map_sem_nth :
forall i f1 f2 vnl vsl d,
map (fun f => sem f vnl vsl) f1 = map (fun f => sem f vnl vsl) f2 ->
sem (nth i f1 d) vnl vsl = sem (nth i f2 d) vnl vsl.
Lemma sem_proj_S_normal :
forall n s i f vsl vnl,
i < n ->
sem (proj (S n) s (S i)) (f::vnl) vsl =
sem (proj n s i) vnl vsl.
Lemma sem_proj_S_safe :
forall n s i f vsl vnl,
n <= i ->
sem (proj n (S s) (S i)) vnl (f::vsl) =
sem (proj n s i) vnl vsl.
Lemma sem_firstn_safe :
forall f n s vnl vsl,
arities f = ok_arities n s ->
sem f vnl vsl = sem f vnl (firstn s vsl).
Lemma sem_firstn_normal :
forall f n s vnl vsl,
arities f = ok_arities n s ->
sem f vnl vsl = sem f (firstn n vnl) vsl.
Lemma sem_firstn :
forall f n s vnl vsl,
arities f = ok_arities n s ->
sem f vnl vsl = sem f (firstn n vnl) (firstn s vsl).
Lemma sem_repeat :
forall f vnl vsl n s,
arities f = ok_arities n s ->
sem f vnl vsl = sem f (vnl ++ repeat (n - length vnl) nil) (vsl ++ repeat (s - length vsl) nil).
Lemma map_sem_repeat :
forall fl vnl vsl n s,
(forall f, In f fl -> arities f = ok_arities n s) ->
map (fun f => sem f vnl vsl) fl =
map (
fun f =>
sem f
(vnl ++ repeat (n - length vnl) nil)
(vsl ++ repeat (s - length vsl) nil)
) fl.
Lemma map_proj_seq_normal_gen :
forall n i vnl,
n+i <= length vnl ->
map (fun f : BC => sem f vnl nil) (map (proj (n+i) 0) (seq i n)) =
firstn n (skipn i vnl).
Lemma map_proj_seq_normal :
forall n vnl,
map (fun f : BC => sem f vnl nil) (map (proj n 0) (seq 0 n)) =
firstn n vnl ++ repeat (n - length vnl) nil.
Lemma map_proj_seq_safe_gen :
forall n s i vnl vsl,
s+i <= length vsl ->
map (fun f : BC => sem f vnl vsl) (map (proj n (s+i)) (seq (n+i) s)) =
firstn s (skipn i vsl).
Lemma map_proj_seq_safe :
forall n s vnl vsl,
map (fun f : BC => sem f vnl vsl) (map (proj n s) (seq n s)) =
firstn s vsl ++ repeat (s - length vsl) nil.