The “vsubst: Bad substitution list” exception in HOL Light occurs when the vsubst (variable substitution) function receives an invalid list of variable substitutions. This error arises during term manipulation, usually when trying to replace variables with terms that do not match the expected type or structure of the variables being replaced. Common Causes and Fixes
Incorrect Substitution Pairs (Variable → Term): The vsubst function requires a list of pairs where a variable (or a term intended as a variable) is replaced by another term. If you provide a pair where the first element is not a variable, vsubst will fail.
Fix: Ensure the substitution list consists of (term_var, term_new) pairs, where term_var is a variable (e.g., x, y).
Type Mismatch in Substitution: The new term must have the exact same type as the variable it is replacing.
Fix: Check that the types match. If the variable is :num, the replacement term must be :num.
Variable Shadowing/Context Issues: If the variable you are attempting to substitute is bound by a lambda ( λ ) or a quantifier (∀, ∃) within the larger term, vsubst may fail, especially if the substitution is improperly applied to the theorem’s structure.
Fix: Use INST or INST_TYPE for substituting variables/types in theorems rather than vsubst on a term, or ensure you are applying the substitution to the free variables correctly. Example Scenario (From HOL Light Tutorial)
The error often appears during INST (instantation) when applied improperly:
# INST [‘2’, ‘2n’] th2;; Exception: Failure “vsubst: Bad substitution list”. Use code with caution.
Why: The INST function requires a list of pairs (e.g., [‘2’, ‘n’] means replace n with 2), but the example above likely provided incorrect or malformed terms to the INST function, prompting a vsubst error internally. How to Debug
Inspect the Substitution List: Before calling vsubst, inspect your substitution list to make sure it is in the format (term, term) list.
Validate Free Variables: Use frees thm to ensure the variables you are targeting are actually free variables in the theorem or term. If you are encountering this error,I can help you: Validate the types in your substitution list. Structure the pair to avoid the error. Identify if INST is the correct function to use. HOL Light Tutorial
Leave a Reply