From Undecidability.Shared.Libs.PSL Require Import FinTypes Base.
From Undecidability.Shared.Libs.PSL Require Import Bijection.
(* Require Import Vector. *)
(* Definition vector X Y := Vector.t Y (|elem X|). *)
Definition finfunc_table (A : finType) (B: Type) (f: A -> B) :=
List.map (fun x => (x, f x)) (elem A).
(* Now we prove that the tranformation of a function of finite domain to a table is correct *)
Definition lookup (A : eqType) (B : Type) (l : list (A * B)) (a : A) (def : B) : B :=
match (filter (fun p => Dec (fst p = a)) l) with
List.nil => def
| p :: _ => snd p
end.

Lemma lookup_complete (A: eqType) (B: Type) (L : list (prod A B)) a def :
{(a,lookup L a def) el L } + {~(exists b, (a,b) el L) /\ lookup L a def  = def}.