Section RESTRICT_STRUCTURE.
#[local] Existing Instance V.vec_isSetoid.
#[local]
Instance restrict_structure (STRUCTURE : isStructureOf L') : isStructureOf L :=
{ domain_of_discourse := STRUCTURE.(domain_of_discourse)
; equation_interpret := STRUCTURE.(equation_interpret)
; function_interpret (f : L.(function_symbols)) := STRUCTURE.(function_interpret) f
; constant_interpret (c : L.(constant_symbols)) := STRUCTURE.(constant_interpret) (inl c)
; relation_interpret (R : L.(relation_symbols)) := STRUCTURE.(relation_interpret) R
; domain_is_nonempty := STRUCTURE.(domain_is_nonempty)
; function_interpret_preserves_eqProp := STRUCTURE.(function_interpret_preserves_eqProp)
; relation_interpret_preserves_eqProp := STRUCTURE.(relation_interpret_preserves_eqProp)
}.
End RESTRICT_STRUCTURE.
Fixpoint twilight_trm' (t : trm L') : trm L :=
match t with
| Var_trm x => @Var_trm L (x * 2)
| Fun_trm f ts => @Fun_trm L f (twilight_trms' ts)
| Con_trm c =>
match c with
| inl cc => @Con_trm L cc
| inr hc => @Var_trm L (hc * 2 + 1)
end
end
with twilight_trms' {n : nat} (ts : trms L' n) : trms L n :=
match ts with
| O_trms => @O_trms L
| S_trms n t ts => @S_trms L n (twilight_trm' t) (twilight_trms' ts)
end.
#[local] Hint Rewrite twilight_trm_decomposition twilight_trms_decomposition : simplication_hints.
#[local] Hint Rewrite twilight_frm_decomposition.
Fixpoint unembed_trm (t : trm L') : trm L :=
match t with
| Var_trm x => @Var_trm L x
| Fun_trm f ts => @Fun_trm L f (unembed_trms ts)
| Con_trm c =>
match c with
| inl cc => @Con_trm L cc
| inr hc => @Var_trm L hc
end
end
with unembed_trms {n : nat} (ts : trms L' n) : trms L n :=
match ts with
| O_trms => @O_trms L
| S_trms n t ts => @S_trms L n (unembed_trm t) (unembed_trms ts)
end.

Lemma unembed_trms_unfold n (ts : trms L' n) :
unembed_trms ts =
match ts with
| O_trms => @O_trms L
| S_trms n t ts => @S_trms L n (unembed_trm t) (unembed_trms ts)
end.