Functions

This module defines the notation for function composition and extentional equality . It further defines pairing, the product of functions and the final map.
Extentional equality on functions is very simple here: It uses Coq equality on the results. This is sufficient. The reasoning about extentional equality is always explicit, because I am not (yet) familiar with setoid rewriting.

composition


Definition fcompose{X Y Z : Type}(f : YZ)(g : XY)(x : X) : Z :=
  f(g(x)).

Hint Unfold fcompose.

Notation " f ∘ g " := (fcompose f g)
  (at level 40, left associativity) : feq_scope.

extentional equality


Definition function_equal {X Y : Type}(f g : XY) :=
   x : X, f x = g x.

Notation " g ≡ f " := (function_equal g f)
  (at level 70) : feq_scope.

Open Scope feq_scope.

Lemma feq_reflexive : (X Y : Type)(f : XY), f f.

Lemma feq_transitive :
   (X Y : Type)(f g h : XY), f gg hf h.

Lemma feq_symmetric : (X Y : Type)(f g : XY), f gg f.

Lemma feq_eq : (X Y : Type)(f g : XY), f = gf g.


Lemma feq_rw_r : (X Y : Type)(f g h : XY),
  g hf hf g.

identity


Definition id {X : Type} : XX := fun xx.

Lemma feq_id_left : (X Y : Type)(f : XY), (id f) f.

Lemma feq_id_right : (X Y : Type)(f : XY), (f id) f.

composition laws


Lemma feq_compose_associative :
   (U V X Y : Type)(f : XY)(g : VX)(h : UV),
    (f (g h)) (f g h).

Lemma feq_compose_associative_reverse :
   (U V X Y : Type)(f : XY)(g : VX)(h : UV),
    (f g h) (f (g h)).

Lemma feq_compose_both :
   (X Y Z : Type)(f1 f2: YZ)(g1 g2 : XY),
    f1 f2g1 g2(f1 g1) (f2 g2).

Lemma feq_compose_left_both :
   (X Y Z : Type)(f : YZ)(g1 g2 : XY),
    g1 g2(f g1) (f g2).

Lemma feq_compose_right_both :
   (X Y Z : Type)(f1 f2 : YZ)(g : XY),
    f1 f2(f1 g) (f2 g).

Lemma feq_left_compose_left :
  (X Y Z : Type)(f1 f2 : YZ)(g : XY)(h : XZ),
    f1 f2f2 g hf1 g h.

Lemma feq_left_compose_right :
  (X Y Z : Type)(f1 f2 : YZ)(g : XZ)(h : XY),
    f1 f2g f2 hg f1 h.

Lemma feq_right_compose_left :
  (X Y Z : Type)(f : YZ)(g1 g2 : XY)(h : XZ),
    g1 g2f g2 hf g1 h.

Lemma feq_right_compose_right :
  (X Y Z : Type)(f1 f2 : XY)(g : XZ)(h : YZ),
    f1 f2g h f2g h f1.

final object



Definition final_map(X : Type) : Xunit := fun _tt.

Lemma final_map_prop : (X : Type)(f : Xunit),
  f final_map X.

product, pairing


Definition pair{U X Y : Type}(f : UX)(g : UY) : UX × Y :=
  fun(u : U) ⇒ (f u, g u).

Lemma pair_proj_left :
  (U X Y : Type)(f : UX)(g : UY),
    (@fst X Y) (pair f g) = f.

Lemma pair_proj_right :
  (U X Y : Type)(f : UX)(g : UY),
    (@snd X Y) (pair f g) = g.

Lemma pair_compose_right :
  (U V X Y : Type)(h : UV)(f : VX)(g : VY),
    (pair f g) h = pair (f h) (g h).

Lemma feq_pair_proj : (U X Y : Type)(f : UX × Y),
  f pair ((fst (B := Y)) f) ((snd (B := Y)) f).

Lemma feq_pair_both :
  (X Y Z : Type)(f1 f2 : XY)(g1 g2 : XZ),
    f1 f2g1 g2pair f1 g1 pair f2 g2.

Lemma feq_pair_left :
  (X Y Z : Type)(f1 f2 : XY)(g : XZ),
    f1 f2pair f1 g pair f2 g.

Lemma feq_pair_right :
  (X Y Z : Type)(f : XY)(g1 g2 : XZ),
    g1 g2pair f g1 pair f g2.

product map


Definition ftimes{U V X Y : Type}(f : UX)(g : VY) : U × VX × Y :=
  fun(uv : U × V) ⇒ (f (fst uv), g (snd uv)).

Lemma ftimes_def :
  (U V X Y : Type)(f : UX)(g : VY),
    pair (f (fst (B := V))) (g (snd (B := V))) = ftimes f g.

Lemma feq_ftimes_id : (X Y : Type),
  ftimes (@id X) (@id Y) @id (X × Y).

Lemma feq_ftimes_compose :
  (XL XR YL YR ZL ZR : Type)
        (fl : XLYL)(fr : XRYR)(gl : YLZL)(gr : YRZR),
    (ftimes gl gr) (ftimes fl fr) ftimes (gl fl) (gr fr).

Lemma feq_ftimes_compose_pair :
  (X YL YR ZL ZR : Type)
        (fl : XYL)(fr : XYR)(gl : YLZL)(gr : YRZR),
    (ftimes gl gr) (pair fl fr) pair (gl fl) (gr fr).

Lemma feq_ftimes_both :
  (U V X Y : Type)(f1 f2 : UX)(g1 g2 : VY),
    f1 f2g1 g2ftimes f1 g1 ftimes f2 g2.

Lemma feq_ftimes_left :
  (U V X Y : Type)(f1 f2 : UX)(g : VY),
    f1 f2ftimes f1 g ftimes f2 g.

Lemma feq_ftimes_right :
  (U V X Y : Type)(f : UX)(g1 g2 : VY),
    g1 g2ftimes f g1 ftimes f g2.