Library LangAlg.finite_functions
We prove here that there is a finite number of functions between
two finite decidable sets.
We will consider here maps modulo function extensionality.
eqf is an equivalence relation.
We assume the source and target of our functions are decidable.
hom is the type of partial functions.
We use a somewhat relaxed notion of range here: we say that m
is a range of f if every value produced by f appears in the
list m. Note that m could contain more values.
Fixpoint finite_functions (l :list src) (m : list trg) :=
match l with
| [] ⇒ [fun _ ⇒ None]
| a::l ⇒
bimap (fun f b n ⇒ if eqX n a then Some b else f n)
(finite_functions l m) m
end.
match l with
| [] ⇒ [fun _ ⇒ None]
| a::l ⇒
bimap (fun f b n ⇒ if eqX n a then Some b else f n)
(finite_functions l m) m
end.
If f is a finite function from l to m, there is an
extensionally equivalent function g in the list
finite_functions l m.
Lemma finite_function_is_finite l m f :
finite_function f l m →
∃ g, g ∈ (finite_functions l m) ∧ f ≃ g.
finite_function f l m →
∃ g, g ∈ (finite_functions l m) ∧ f ≃ g.
If we're given a default value, we can complete a partial
function as a total function.
Given a list l and a total function f, we can compute a
partial function whose domain is l and whose values are those of
f.
We define finite support for total function using the default
value y0 instead of the undefined value None we used for partial
functions.
If f has finite support, then its restriction to its domain is
a finite function, and f is extensionally equivalent to the
completion of its restriction.
Lemma finite_support_finite_function f l m y0 :
finite_support f l m y0 →
finite_function (restriction l f) l m
∧ f ≃ make_total y0 (restriction l f).
finite_support f l m y0 →
finite_function (restriction l f) l m
∧ f ≃ make_total y0 (restriction l f).
Translates the list of finite partial functions into a list of
finitely supported total functions.
This list is exhaustive.