to_var t returns x if t is of the form Vari x and fails otherwise.
NOTE the Array.map to_var function is useful when working with multiple binders. For example, this is the case when manipulating pattern variables (Patt constructor) or metatavariables (Meta constructor). Remark that it is important for these constructors to hold an array of terms, rather than an array of variables: a variable can only be substituted when if it is injected in a term (using the Vari constructor).
NOTE the result of to_var can generally NOT be precomputed. A first reason is that we cannot know in advance what variable identifier is going to arise when working under binders, for which fresh variables will often be generated. A second reason is that free variables should never be “marshaled” (e.g., by the Sign module), as this would break the freshness invariant of new variables.
If ts is not made of variables or function symbols prefixed by '$' only, then nl_distinct_vars ts returns None. Otherwise, it returns a pair (vs, map) where vs is an array of variables made of the linear variables of ts and fresh variables for the non-linear variables and the symbols prefixed by '$', and map records by which variable each linear symbol prefixed by '$' is replaced.
The symbols prefixed by '$' are introduced by infer.ml which converts metavariables into fresh symbols, and those metavariables are introduced by sr.ml which replaces pattern variables by metavariables.