Section GENERAL_CASE.
Context (_constant_symbols' : Set) (L' := mkL_with_constant_symbols _constant_symbols').
Hypothesis constant_symbols_similarity : Similarity _constant_symbols _constant_symbols'.
Inductive trm_similarity : Similarity (trm L) (trm L') :=
| Var_sim (x : ivar)
: @Var_trm L x =~= @Var_trm L' x
| Fun_sim (f : _function_symbols) (ts : trms L (L.(function_arity_table) f)) (ts' : trms L' (L'.(function_arity_table) f))
(ts_SIM : ts =~= ts')
: @Fun_trm L f ts =~= @Fun_trm L' f ts'
| Con_sim (c : _constant_symbols) (c' : _constant_symbols')
(c_SIM : c =~= c')
: @Con_trm L c =~= @Con_trm L' c'
with trms_similarity : forall n : arity, Similarity (trms L n) (trms L' n) :=
| O_trms_sim
: @O_trms L =~= @O_trms L'
| S_trms_sim (n : arity) (t : trm L) (t' : trm L') (ts : trms L n) (ts' : trms L' n)
(t_SIM : t =~= t')
(ts_SIM : ts =~= ts')
: @S_trms L n t ts =~= @S_trms L' n t' ts'.
#[local] Instance trm_similarity_instance : Similarity (trm L) (trm L') :=
trm_similarity.
#[local] Instance trms_similarity_instance (n : arity) : Similarity (trms L n) (trms L' n) :=
trms_similarity n.
Inductive frm_similarity : Similarity (frm L) (frm L') :=
| Rel_sim (R : _relation_symbols) (ts : trms L (L.(relation_arity_table) R)) (ts' : trms L' (L'.(relation_arity_table) R))
(ts_SIM : ts =~= ts')
: @Rel_frm L R ts =~= @Rel_frm L' R ts'
| Eqn_sim (t1 : trm L) (t1' : trm L') (t2 : trm L) (t2' : trm L')
(t1_SIM : t1 =~= t1')
(t2_SIM : t2 =~= t2')
: @Eqn_frm L t1 t2 =~= @Eqn_frm L' t1' t2'
| Neg_sim (p1 : frm L) (p1' : frm L')
(p1_SIM : p1 =~= p1')
: @Neg_frm L p1 =~= @Neg_frm L' p1'
| Imp_sim (p1 : frm L) (p1' : frm L') (p2 : frm L) (p2' : frm L')
(p1_SIM : p1 =~= p1')
(p2_SIM : p2 =~= p2')
: @Imp_frm L p1 p2 =~= @Imp_frm L' p1' p2'
| All_sim (y : ivar) (p1 : frm L) (p1' : frm L')
(p1_SIM : p1 =~= p1')
: @All_frm L y p1 =~= @All_frm L' y p1'.
#[local] Instance frm_similarity_instance : Similarity (frm L) (frm L') :=
frm_similarity.
Proof with eauto with *.
- induction t_SIM.
+ reflexivity.
+ change (fvs_trms ts = fvs_trms ts'). eapply fvs_trms_compat_similarity. exact ts_SIM.
+ reflexivity.
- induction ts_SIM.
+ reflexivity.
+ change (fvs_trm t ++ fvs_trms ts = fvs_trm t' ++ fvs_trms ts'). f_equal...
Qed.

Lemma fvs_frm_compat_similarity (p : frm L) (p' : frm L')
(p_SIM : p =~= p')
: fvs_frm p = fvs_frm p'.