Section TWILIGHT.
Definition twilight (sigma : hsubst) : subst L' :=
fun z : ivar => sigma (enum (isEnumerable := @sum_isEnumerable ivar Henkin_constants nat_isEnumerable nat_isEnumerable) z).
Fixpoint twilight_trm (t : trm L') : trm L' :=
match t with
| Var_trm x => Var_trm (x * 2)
| Fun_trm f ts => Fun_trm f (twilight_trms ts)
| Con_trm c =>
match c with
| inl cc => Con_trm c
| inr hc => Var_trm (hc * 2 + 1)
end
end
with twilight_trms {n : nat} (ts : trms L' n) : trms L' n :=
match ts with
| O_trms => O_trms
| S_trms n t ts => S_trms n (twilight_trm t) (twilight_trms ts)
end.
Fixpoint twilight_frm (p : frm L') : frm L' :=
match p with
| Rel_frm R ts => Rel_frm R (twilight_trms ts)
| Eqn_frm t1 t2 => Eqn_frm (twilight_trm t1) (twilight_trm t2)
| Neg_frm p1 => Neg_frm (twilight_frm p1)
| Imp_frm p1 p2 => Imp_frm (twilight_frm p1) (twilight_frm p2)
| All_frm y p1 => All_frm (2 * y) (twilight_frm p1)
end.

Lemma twilight_trm_spec (t : trm L')
: twilight_trm t = hsubst_trm (fun z : hatom => match z with inl x => Var_trm (x * 2) | inr hc => Var_trm (hc * 2 + 1) end) t
with twilight_trms_spec n (ts : trms L' n)
: twilight_trms ts = hsubst_trms (fun z : hatom => match z with inl x => Var_trm (x * 2) | inr hc => Var_trm (hc * 2 + 1) end) ts.