(** the transposition of h is the hedge where all the pairs (M,N) are reversed in (N,M) *)
Definition transpose (h : hedge) (M N : Msg) := h N M.(** h is consistent if h is left consistent and if (transpose h) is left consistent (h is right consistent) *)
Definition is_consistent (h : hedge) :=
  is_left_consistent h /\ is_left_consistent (transpose h).Definition no_pairs (h : hedge) :=
  forall M1 M2 N1 N2 : Msg, ~ h (MPair M1 M2) (MPair N1 N2).Definition no_syn_ops (h : hedge) :=
  forall (o : op) (M N : Msg), h (Mop o M) (Mop o N) -> ~ synthesis h M N.Definition no_syn_cyph (h : hedge) :=
  forall M N K L : Msg,
  h (MEnc M K) (MEnc N L) -> ~ synthesis h M N \/ ~ synthesis h K L.Definition cyph_dec (h : hedge) :=
  forall M N K L : Msg,
  h (MEnc M K) (MEnc N L) -> synthesis h (inv K) (inv L) -> synthesis h M N.(** we show in the following that a hedge is irreducible iff it satisfies these conditions *)
Definition cond_irr (h : hedge) :=
  no_pairs h /\ no_syn_ops h /\ no_syn_cyph h /\ cyph_dec h.

(* Specifications: *)
Lemma left_consistent_impl_cond_irr_strong : forall h : hedge, name_left_name h /\ injective_left h /\ op_synthesis_left h /\ pair_free_left h /\ enc_synthesis_left h /\ enc_analysis_left h -> cond_irr h.
Lemma left_consistent_impl_cond_irr : forall h : hedge, is_left_consistent h -> cond_irr h.
Lemma consistent_impl_cond_irr : forall h : hedge, is_consistent h -> cond_irr h.
Lemma cond_irr_impl_le_h_ana : forall h : hedge, cond_irr h -> le_h (analysis_def h) h.
Lemma cond_irr_impl_equiv_h_irr : forall h : hedge, cond_irr h -> equiv_h h (irreducible h).
Lemma cond_irr_impl_irr_incl_h : forall h : hedge, cond_irr h -> inclusion (irreducible h) h.
Lemma cond_irr_impl_stable_reduce : forall h : hedge, cond_irr h -> equal h (reduce h).
Lemma cond_irr_impl_h_incl_irr : forall h : hedge, cond_irr h -> inclusion h (irreducible h).
Lemma cond_irr_impl_irreducible : forall h : hedge, cond_irr h -> is_irreducible h.
Lemma irreducible_impl_cond_irr : forall h : hedge, is_irreducible h -> cond_irr h.
Theorem irreducible_iff_cond_irr : forall h : hedge, cond_irr h <-> is_irreducible h.
Theorem consistent_impl_irreducible : forall h : hedge, is_consistent h -> is_irreducible h.
Theorem equiv_consistent_consistent_equal : forall g h : hedge, equiv_h g h -> is_consistent g -> is_consistent h -> equal g h.
Lemma inclusion_transpose_inclusion : forall g h : hedge, inclusion g h -> inclusion (transpose g) (transpose h).
Lemma equal_transpose_equal : forall g h : hedge, equal g h -> equal (transpose g) (transpose h).
Lemma transpose_invol : forall h : hedge, equal h (transpose (transpose h)).
Lemma synthesis_transpose_transpose_synthesis : forall h : hedge, equal (synthesis (transpose h)) (transpose (synthesis h)).
Lemma le_h_transpose_le_h : forall g h : hedge, le_h g h -> le_h (transpose g) (transpose h).
Lemma irr_le_h_left_consistent_impl_left_consistent_weak : forall g h : hedge, is_irreducible g -> is_left_consistent h -> le_h g h -> weak_left_consistent g.
Lemma weak_left_consistent_inj_inv_left_iff_left_consistent : forall h : hedge, weak_left_consistent h /\ injective_inv_left h <-> is_left_consistent h.
Theorem irr_le_h_left_consistent_impl_left_consistent : forall g h : hedge, is_irreducible g -> is_left_consistent h -> le_h g h -> is_left_consistent g.
Lemma reduce_transpose_transpose_reduce : forall h : hedge, equal (reduce (transpose h)) (transpose (reduce h)).
Lemma analysis_transpose_transpose_analysis : forall h : hedge, equal (analysis (transpose h)) (transpose (analysis h)).
Lemma stable_impl_transpose_stable : forall h : hedge, stable_analysis h -> stable_analysis (transpose h).
Lemma ana_transpose_incl_transpose_ana : forall h : hedge, inclusion (analysis_def (transpose h)) (transpose (analysis_def h)).
Lemma transpose_ana_transpose_incl_ana : forall h : hedge, inclusion (transpose (analysis_def (transpose h))) (analysis_def h).
Lemma ana_incl_transpose_ana_transpose : forall h : hedge, inclusion (analysis_def h) (transpose (analysis_def (transpose h))).
Lemma ana_transpose_transpose_ana : forall h : hedge, equal (analysis_def (transpose h)) (transpose (analysis_def h)).
Lemma irr_transpose_transpose_irr : forall h : hedge, equal (irreducible (transpose h)) (transpose (irreducible h)).
Lemma is_irreducible_transpose_is_irreducible : forall h : hedge, is_irreducible h -> is_irreducible (transpose h).
Theorem irr_le_h_consistent_impl_consistent : forall g h : hedge, is_irreducible g -> is_consistent h -> le_h g h -> is_consistent g.