Validate a variable.
(valid-var var table) → (mv erp type)
This is used to validate the
A variable (i.e. identifier) is valid if it is found in the validation table, recorded as denoting an object or function [C:6.5.1/2]. The type is obtained from the table.
Function:
(defun valid-var (var table) (declare (xargs :guard (and (identp var) (valid-tablep table)))) (let ((__function__ 'valid-var)) (declare (ignorable __function__)) (b* (((reterr) (irr-type)) ((mv info &) (valid-lookup-ord var table)) ((unless info) (reterr (msg "The variable ~x0 is not in scope." (ident-fix var)))) ((unless (valid-ord-info-case info :objfun)) (reterr (msg "The identifier ~x0, used as a variable, ~ is in scope, but does not denote ~ an object or function." (ident-fix var))))) (retok (valid-ord-info-objfun->type info)))))
Theorem:
(defthm typep-of-valid-var.type (b* (((mv acl2::?erp ?type) (valid-var var table))) (typep type)) :rule-classes :rewrite)
Theorem:
(defthm valid-var-of-ident-fix-var (equal (valid-var (ident-fix var) table) (valid-var var table)))
Theorem:
(defthm valid-var-ident-equiv-congruence-on-var (implies (ident-equiv var var-equiv) (equal (valid-var var table) (valid-var var-equiv table))) :rule-classes :congruence)
Theorem:
(defthm valid-var-of-valid-table-fix-table (equal (valid-var var (valid-table-fix table)) (valid-var var table)))
Theorem:
(defthm valid-var-valid-table-equiv-congruence-on-table (implies (valid-table-equiv table table-equiv) (equal (valid-var var table) (valid-var var table-equiv))) :rule-classes :congruence)