edit 2 : . Given that Bruijn indices may be easier to work with, I reformulated most of the internal representation of formulas to use the mixed Brain View of Al Connor McBride. This greatly simplified some syntax algorithms associated with α-equivalence, but made others more complex. In any case, this means that free variables can be standardized separately, and related variables have canonical names represented by their binding distance. This is not entirely satisfactory, but it is at least a better start.
edit 1 : I realized that problematic constraints are not enough to ensure the standardization of variables. In particular, the iteration of quantifiers means that first the variables in the binders must be standardized from each other. Thus, there is probably no way out of a solution that requires several passes over each abstract syntax tree. The proposal to use Bruijn indexes is a pretty good solution in general, but it will not allow standardization easily without violating the notation and its usefulness.
original:
Let V be an infinite set of variables indexed by natural numbers, fv (φ) denote free variables φ, and bv (φ) denote coupled variables φ for any first-order formula φ. The problem I'm trying to solve is the following.
Let φ and ψ be first-order formulas. Find permutations θ 1 and θ 2 such that: (a) fv (θ 1 (φ)), fv (θ 2 (φ)), bv (θ 1 (φ)), and bv (θ 2 (ψ)) do not overlap; (b) the union fv (θ 1 (φ)), fv (θ 2 (φ)), bv (θ 1 (φ)), and bv (θ 2 (ψ)) is isomorphic to the initial segment of natural numbers; and (c) all variables in bv (θ 1 (ψ)) are less than all variables in bv (θ 2 (ψ)) are less than all variables in fv (θ 1 (ψ)) are less than all variables in fv (θ 2 (ψ) )
, , , , ..
. φ ψ, φ ψ , φ ψ, φ ' ψ'. φ ', x 0. ψ '. '. ψ '.
, . , , . . .