induction keys; intuition; simpl in *.
inversion H; clear H; subst.
simpl.
trivial.
inversion H; clear H; subst.
intuition.
simpl.
case_eq (arrayLookup (pair_EqDec eqda eqdb) a2 (a0, b)); intuition.
rewrite  arrayLookup_pair_None in H0.
discriminate.
intuition.
subst.
eapply H.
symmetry.
eapply H3.
trivial.
rewrite arrayLookup_app_None; trivial.
eauto.
Qed.

Theorem arrayLookup_flatten_eq :
forall (A B C : Set)(eqda : EqDec A)(eqdb : EqDec B)(ls : list (list (A * B * C))) keys a b,
list_pred (fun a b => forall x, In x b -> fst (fst x) = a) keys ls ->
NoDup keys ->
arrayLookup _ (flatten ls) (a, b) =
arrayLookup _ (arrayLookupList _ (combine keys ls) a) (a, b).