Section NthOrderSystemUnification.
Variable (X: Const).
Implicit Types (sigma: fin -> exp X) (e: eq X) (E : eqs X).
Definition eq_ordertyping n Gamma e A := Gamma ⊢(n) fst e : A /\ Gamma ⊢(n) snd e : A.
Notation "Gamma ⊢₂( n ')' e : A" := (eq_ordertyping n Gamma e A) (at level 80, e at level 99).
Reserved Notation  "Gamma ⊢₊₊( n ) E : L" (at level 80, E at level 99).
Inductive eqs_ordertyping Gamma n : eqs X -> list type -> Prop :=
| eqs_ordertyping_nil: Gamma ⊢₊₊(n) nil : nil
| eqs_ordertyping_cons s t  A E L: Gamma ⊢(n) s : A -> Gamma ⊢(n) t : A -> Gamma ⊢₊₊(n) E : L -> Gamma ⊢₊₊(n) ((s,t) :: E) : A :: L
where  "Gamma ⊢₊₊( n ) E : L" := (eqs_ordertyping Gamma n E L).
Hint Constructors eqs_ordertyping : core.
Hint Resolve left_typing right_typing left_ordertyping right_ordertyping : core.
Hint Rewrite Vars'_cons Vars'_app : simplify.
Hint Rewrite left_subst_eqs right_subst_eqs : simplify.

Lemma eqs_ordertyping_preservation_subst n Gamma E L Delta sigma:
Gamma ⊢₊₊(n) E : L -> Delta ⊩(n) sigma : Gamma -> Delta ⊢₊₊(n) sigma •₊₊ E : L.