(** ** Boolean operations on [RegExp] are morphism. *)
(** [Or] corresponds to plus in Kleene algebra. *)
Add Parametric Morphism : And with
signature re_eq ==> re_eq ==> re_eq as And_morphism.
Add Parametric Morphism : Not with
signature re_eq ==> re_eq as Not_morphism.
(** [matches] is a homomorphism from [RegExp] to bool for [And], [Or], and [Not]. *)

(* Specifications: *)
Lemma matches_Or : forall s r r',  r || r' ~= s = ((r ~= s) || (r' ~= s))%bool.
Lemma matches_And : forall s r r',  matches (And r r') s = ((r ~= s) && (r' ~= s))%bool.
Lemma matches_Not : forall s r,  (Not r) ~= s = negb (r ~= s).
(** ** Axioms for [Or] *)
(** Commutativity and associativity of [Or] and [And]. *)
Lemma Or_comm_s : forall s r r', (r || r') ~= s = (r' || r) ~= s.
Theorem Or_comm : forall r r', r || r' =R= r' || r.
Lemma Or_assoc_s : forall s r r' r'',
((r || r') || r'') ~= s = (r || (r' || r'')) ~= s.
Theorem Or_assoc : forall r r' r'', (r || r') || r'' =R= r || (r' || r'').
Lemma And_comm : forall r r', And r r' =R= And r' r.
Lemma And_assoc : forall r r' r'', And (And r r') r'' =R= And r (And r' r'').
(** [Empty] is the identity element 0 for [Or]. *)
Lemma Or_left_id_s : forall s r, (Empty || r) ~= s = r ~= s.
Theorem Or_left_id : forall r, Empty || r =R= r.
Theorem Or_right_id : forall r, r || Empty =R= r.
intros.  setoid_rewrite Or_comm.