Utilities

This file contains some facilities (definitions, theorems) to help define / proving some things.
This function create, from two subset A & B of a set C, and a binary operation op : C -> C -> C, a subset of C containing the closure of A & B by op.
Definition set_from_op {C : Type} (op : C→C→C) (A : C → Prop) (B : C→Prop) : C→Prop :=
  fun c ⇒ ∃ a b, A a ∧ B b ∧ c = op a b.
The image of a function can be generically defined as follow.
Definition image {X Y : Type} (f : X → Y) (C : X → Prop) : Y → Prop :=
  fun y ⇒ ∃ x : X, C x ∧ y = f x.
Iterates of a function.
Fixpoint iter {X : Type} (f : X→X) (n : nat) (a : X) : X :=
  match n with
  | 0 ⇒ a
  | S n ⇒ f (iter f n a)
  end.

Fixpoint generic_pow {X : Type} (op : X → X → X) (neutral result : X) (n : nat) : X :=
  match n with
  | 0 ⇒ neutral
  | S n ⇒ op result (generic_pow op neutral result n)
  end.