# Library LangAlg.terms_w_terms

In this module we describe the reductions between terms (type ๐), primed weak terms (๐') and series-parallel terms (๐๐).

Set Implicit Arguments.

Require Export terms w_terms.
Open Scope term_scope.
Section s.
Variable X : Set.
Variable dec_X : decidable_set X.

We start by defining a conversion function from series parallel terms over a duplicated alphabet into terms over the original alphabet.
Using this function, we build a translation from primed weak terms into terms.
Definition ๐'_to_๐ (e : ๐') : ๐ X:=
match e with
| (exist _ (None,A) _) โ โจmap fst Aโฉ
| (exist _ (Some u,A) _ ) โ
โจmap fst Aโฉ โ ๐๐_to_๐ u
end.

For the converse direction, we directly translate terms into primed weak terms.
Fixpoint ๐_to_๐' (e : ๐ X) : ๐' :=
match e with
| 1 โ ๐ญ'
| ๐_var a โ (exist _ (Some (๐๐_var (a,true)),[]) (@balanced_nil X))
| ๐_cvar a โ
(exist _ (Some (๐๐_var (a,false)),[]) (@balanced_nil X))
| e โ f โ (๐_to_๐' e) โ' (๐_to_๐' f)
| e โฉ f โ (๐_to_๐' e) โ' (๐_to_๐' f)
end.

The translation from terms to primed weak terms is monotone with respect to the ordering of ๐'.
The translation from series-parallel terms into terms is size preserving.
The translation from terms to primed weak terms reduces the size.
From weak terms to terms the size may increase, but is bounded as follows:
We may recover the variables of a term by map the first projection to the set of variables of its translation in ๐'.
Going from primed weak terms to terms and back yields an equivalent ๐'-term.
We can relate the variables of a series parallel term (over the duplicated alphabet) with the variables of its corresponding term.
The translation from primed weak terms to terms is monotone.
Going from terms to primed weak terms and back yields an equivalent term.
The translation from primed weak terms into terms is a reduction, in the sense that two ๐' terms are ordered if and only if their images are ordered.
Similarly, the translation from terms to primed weak terms is a reduction.

# Languages

๐๐_to_๐ is language preserving, for interpretations of assignments of the shape ฮ ฯ.
๐'_to_๐ is language preserving, for interpretations of assignments of the shape ฮ ฯ.
So is ๐_to_๐', under similar hypotheses.