A logic-mode guard-verified version of genvar.
(genvar$ pkg-witness prefix n avoid-lst state) → var
This has a stronger guard than genvar
and always returns a symbol (if it does not cause an error).
We use magic-ev-fncall to call genvar,
and check that the result is a symbol.
Hard errors happening in genvar are not suppressed,
i.e. cause
Compared to genvar, this utility requires a state argument. It may also be slightly less efficient due the magic-ev-fncall overhead. However, it can be used in logic-mode guard-verified code that follows a statically typed discipline.
Function:
(defun genvar$ (pkg-witness prefix n avoid-lst state) (declare (xargs :stobjs (state))) (declare (xargs :guard (and (symbolp pkg-witness) (stringp prefix) (maybe-natp n) (symbol-listp avoid-lst)))) (let ((__function__ 'genvar$)) (declare (ignorable __function__)) (b* (((mv erp var) (magic-ev-fncall 'genvar (list pkg-witness prefix n avoid-lst) state nil t)) ((when erp) (raise "Internal error: ~@0" var)) ((unless (symbolp var)) (raise "Internal error: ~x0 is not a symbol." var))) var)))
Theorem:
(defthm symbolp-of-genvar$ (b* ((var (genvar$ pkg-witness prefix n avoid-lst state))) (symbolp var)) :rule-classes :rewrite)