Translate an R1CS (sparse) vector to a PFCS expression.
(r1cs-vector-to-pfcs vec) → expr
We translate the empty vector to the PFCS constant 0. We translate a singleton vector to the element's corresponding PFCS expression. We translate vectors of two or more elements to (nested) PFCS additions; these are nested to the left, so we reverse the vector before the recursion.
Function:
(defun r1cs-vector-to-pfcs-aux (rev-vec) (declare (xargs :guard (r1cs::sparse-vectorp rev-vec))) (let ((__function__ 'r1cs-vector-to-pfcs-aux)) (declare (ignorable __function__)) (cond ((endp rev-vec) (expression-const 0)) ((endp (cdr rev-vec)) (r1cs-vec-elem-to-pfcs (car rev-vec))) (t (make-expression-add :arg1 (r1cs-vector-to-pfcs-aux (cdr rev-vec)) :arg2 (r1cs-vec-elem-to-pfcs (car rev-vec)))))))
Theorem:
(defthm expressionp-of-r1cs-vector-to-pfcs-aux (b* ((expr (r1cs-vector-to-pfcs-aux rev-vec))) (expressionp expr)) :rule-classes :rewrite)
Theorem:
(defthm r1cs-polynomialp-of-r1cs-vector-to-pfcs-aux (b* ((expr (r1cs-vector-to-pfcs-aux rev-vec))) (r1cs-polynomialp expr)) :rule-classes :rewrite)
Function:
(defun r1cs-vector-to-pfcs (vec) (declare (xargs :guard (r1cs::sparse-vectorp vec))) (let ((__function__ 'r1cs-vector-to-pfcs)) (declare (ignorable __function__)) (r1cs-vector-to-pfcs-aux (rev vec))))
Theorem:
(defthm expressionp-of-r1cs-vector-to-pfcs (b* ((expr (r1cs-vector-to-pfcs vec))) (expressionp expr)) :rule-classes :rewrite)
Theorem:
(defthm r1cs-polynomialp-of-r1cs-vector-to-pfcs (b* ((expr (r1cs-vector-to-pfcs vec))) (r1cs-polynomialp expr)) :rule-classes :rewrite)