Definition trace_outputs (tr : list (name * (input + list output))) : nat :=
length (filterMap (fun e => match e with
| (primary, inr [o]) => Some o
| _ => None
end) tr).

(* Specifications: *)
Lemma trace_outputs_app :
forall tr1 tr2,
trace_outputs (tr1 ++ tr2) = trace_outputs tr1 + trace_outputs tr2.