Definition constructor_beq (x1 x2 : constructor) : bool :=
if constructor_eq_dec x1 x2 then true else false.

(* Specifications: *)
Lemma constructor_beq_eq : forall x1 x2, constructor_beq x1 x2 = true <-> x1 = x2.
Fixpoint value_beq (v1 v2 : value) : bool :=
match v1, v2 with
| c_capply c lv, c_capply c' lv' => constructor_beq c c' && list_beq _ value_beq lv lv'
end.
Lemma value_ind2 :
forall (P : value -> Prop),
(forall c l, (forall v, In v l -> P v) -> P (c_capply c l)) ->
forall v, P v.
Lemma value_beq_eq v1 v2 : value_beq v1 v2 = true <-> v1 = v2.
Fixpoint term_beq (t1 t2 : term) : bool :=
match t1, t2 with
| var x, var x' => variable_beq x x'
| capply c lt, capply c' lt' => constructor_beq c c' && list_beq _ term_beq lt lt'
| fapply f lt, fapply f' lt' => function_beq f f' && list_beq _ term_beq lt lt'
| _, _ => false
end.
Lemma term_beq_eq t1 t2 : term_beq t1 t2 = true <-> t1 = t2.
Fixpoint pattern_from_value (v : value) : pattern  :=
match v with
| c_capply c lv => p_capply c (map pattern_from_value lv)
end.