Section Encoding.
Context {X: Const}.
Implicit Type (n c: nat) (x y z: fin) (e: deq) (E: list deq).
Definition varEQ x: eq X :=
(lambda lambda (var 0) (var (S (S x)) (var 1) (var 0)), lambda lambda (var (S (S x))) ((var 0) (var 1)) (var 0)).
Definition constEQ (x: nat): eq X :=
(var x, enc 1).
Definition addEQ (x y z: nat): eq X :=
(add (var x) (var y), var z).
Definition mulEQ (x y z: nat) : eq X :=
(mul (var x) (var y), var z).
Definition eqs (e: deq) : eqs X :=
match e with
| x =ₑ 1 => [varEQ x; constEQ x]
| x +ₑ y =ₑ z => [varEQ x; varEQ y; varEQ z; addEQ x y z]
| x *ₑ y =ₑ z => [varEQ x; varEQ y; varEQ z; mulEQ x y z]
end.
Notation Eqs E := (flat_map eqs E).

Lemma in_Equations q E:
q ∈ Eqs E <-> (exists e, e ∈ E /\ q ∈ eqs e).