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.
Fixpoint unembed_frm (p : frm L') : frm L :=
match p with
| Rel_frm R ts => @Rel_frm L R (unembed_trms ts)
| Eqn_frm t1 t2 => @Eqn_frm L (unembed_trm t1) (unembed_trm t2)
| Neg_frm p1 => @Neg_frm L (unembed_frm p1)
| Imp_frm p1 p2 => @Imp_frm L (unembed_frm p1) (unembed_frm p2)
| All_frm y p1 => @All_frm L y (unembed_frm p1)
end.
#[local] Hint Rewrite unembed_trm_lemma unembed_trms_lemma : simplication_hints.

Lemma unembed_frm_fvs z (p : frm L')
(HC_free : forall c, HC_occurs_in_frm c p = false)
: is_free_in_frm z p = is_free_in_frm z (unembed_frm p).