+(* da spistare *)
+lemma mem_map_forward: ∀A,B.∀f:A→B.∀a,l.
+ mem A a l → mem B (f a) (map ?? f l).
+ #A #B #f #a #l elim l
+ [normalize @False_ind
+ |#b #tl #Hind *
+ [#eqab <eqab normalize %1 % |#memtl normalize %2 @Hind @memtl]
+ ]
+qed.
+
+lemma memb_to_mem: ∀S:DeqSet.∀l,a. memb S a l =true → mem S a l.
+#S #l #a elim l
+ [normalize #H destruct
+ |#b #tl #Hind #mema cases (orb_true_l … mema)
+ [#eqab >(\P eqab) %1 % |#memtl %2 @Hind @memtl]
+ ]
+qed.
+
+lemma trans_to_match:
+ ∀n.∀h.∀trans: trans_source n → trans_target n.
+ ∀inp,outp,qin,cin,qout,cout,mv. trans inp = outp →
+ tuple_of_pair n h 〈inp,outp〉 = mk_tuple qin cin qout cout mv →
+ match_in_table (S n) qin cin qout cout mv (flatten ? (tuples_of_pairs n h (graph_enum ?? trans))).
+#n #h #trans #inp #outp #qin #cin #qout #cout #mv #Htrans #Htuple
+@(tuple_to_match … (refl…)) <Htuple @mem_map_forward
+@(memb_to_mem (FinProd (trans_source n) (trans_target n)))
+@graph_enum_complete //
+qed.
+
+(*
+lemma trans_to_match:
+ ∀n.∀h.∀trans: trans_source n → trans_target n.
+ ∀inp,outp,qin,cin,qout,cout,mv. trans inp = outp →
+ tuple_of_pair n h 〈inp,outp〉 = mk_tuple qin cin qout cout mv →
+ match_in_table (S n) qin cin qout cout mv (flatten ? (tuples_of_pairs n h (graph_enum ?? trans))).
+#n #h #trans #inp #outp #qin #cin #qout #cout #mv #Htrans #Htuple
+@(tuple_to_match … (refl…)) <Htuple @mem_map_forward
+@(memb_to_mem (FinProd (trans_source n) (trans_target n)))
+@graph_enum_complete //
+qed. *)
+
+
+(*
+lemma trans_to_match:
+ ∀n.∀h.∀trans: trans_source n → trans_target n.
+ ∀q,a,qn,action,qin,cin. trans 〈q,a〉 = 〈qn,action〉 →
+ qin = m_bits_of_state n h q →
+ cin = match a with [ None ⇒ null | Some b ⇒ bit b ] →
+ ∃qout,cout,mv.
+ qout = m_bits_of_state n h qn ∧
+ (〈cout,mv〉 = match action with
+ [ None ⇒ 〈null,null〉
+ | Some act ⇒ let 〈na,m〉 ≝ act in
+ match m with [ R ⇒ 〈bit na,bit true〉 | L ⇒ 〈bit na,bit false〉 | N ⇒ 〈bit na,null〉] ]) ∧
+ match_in_table (S n) qin 〈cin,false〉 qout 〈cout,false〉 〈mv,false〉 (flatten ? (tuples_of_pairs n h (graph_enum ?? trans))).
+#n #h #trans #q #a #qn #action #qin #cin #Htrans #Hqin #Hcin
+@(ex_intro … (m_bits_of_state n h qn))
+@(ex_intro … ?) [|@(ex_intro ?) [| % [ % [% | //]]
+@(tuple_to_match … (refl…)) *)
\ No newline at end of file