Section Lookup.
Variable X Y : Type.
Context {eqbX : X -> X -> bool}.
Context `{eqbClass X eqbX}.
Fixpoint lookup (x:X) (A:list (X*Y)) d: Y :=
match A with
[] => d
| (key,Lproc)::A =>
if eqb x key then Lproc else lookup x A d
end.
Context `{registered X} `{@eqbCompT X _ eqbX _}.
Definition lookupTime (x:nat) (l:list (X*Y)):=
fold_right (fun '(a,b) res => eqbTime (X:=X) x (size (enc (a:X))) + res +24) 4 l.
Global Instance term_lookup `{registered Y}:
computableTime' (lookup) (fun x _ => (5, fun l _ => (1, fun d _ => (lookupTime (size (enc x)) l,tt)))).
unfold lookup. unfold eqb.
extract. unfold lookupTime. solverec.
Qed.

Lemma lookupTime_leq x (l:list (X*Y)):
lookupTime x l <= length l * (x* c__eqbComp X + 24) + 4.