We describe the theoretical underpinnings to support the construction of an extension to the Isabelle/HOL theorem prover to support the creation of datatypes for weak higher-order abstract syntax, and give an example of its application. This theoretical basis is centered around the concept of variable types (i.e. types whose elements are variables), and the concept of two terms in a given type having the "same structure" up to a given set of substitutions (the difference set) of one variable for another as allowed by that set. We provide an axiomatization of types for which the notion of having the same structure is well-behaved with the axiomatic class of same struct thy. We show that being a same struct thy is preserved by products, sums and certain function spaces. Within a same struct thy, not all terms necessarily have the same structure as anything, including themselves. Those terms having the same structure as themselves relative to the empty difference set are said to be proper. A proper function from variables to terms corresponds to an abstraction of a variable in a term and also corresponds to substitution of variables for that variable in the term. Proper functions form the basis for a formalization of weak higherorder abstract syntax.