Fixpoint subst_t x y (t : term) : term :=
  match t with
  | V v => if Dec (v = x) then y else V v
  | P p => P p
  | t_e => t_e
  | t_f b t => t_f b (subst_t x y t)
  end.Fixpoint subst {b} x t phi :=
  match phi with
  | Pr t1 t2 => Pr (subst_t x t t1) (subst_t x t t2)
  | Q => Q
  | Fal => Fal
  | Impl phi1 phi2 => Impl (subst x t phi1) (subst x t phi2)
  | All v phi => All v (if Dec (x = v) then phi else subst x t phi)
  end.Definition consts_l {b} A := flat_map (@consts b) A.Definition fresh (y : var) A := ~ y el A.

Lemma mkfresh_spec l a : a el l -> a < mkfresh l.