Check if a PFCS expression is an R1CS polynomial.
(r1cs-polynomialp expr) → yes/no
This is a linear combination, i.e. a sum of one or more monomials.
Currently the PFCS abstract syntax only has binary addition. We pick left-associated additions as linear polynomials; the base case is that of a single monomial.
Function:
(defun r1cs-polynomialp (expr) (declare (xargs :guard (expressionp expr))) (let ((__function__ 'r1cs-polynomialp)) (declare (ignorable __function__)) (or (r1cs-monomialp expr) (and (expression-case expr :add) (r1cs-polynomialp (expression-add->arg1 expr)) (r1cs-monomialp (expression-add->arg2 expr))))))
Theorem:
(defthm booleanp-of-r1cs-polynomialp (b* ((yes/no (r1cs-polynomialp expr))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm r1cs-polynomialp-of-expression-fix-expr (equal (r1cs-polynomialp (expression-fix expr)) (r1cs-polynomialp expr)))
Theorem:
(defthm r1cs-polynomialp-expression-equiv-congruence-on-expr (implies (expression-equiv expr expr-equiv) (equal (r1cs-polynomialp expr) (r1cs-polynomialp expr-equiv))) :rule-classes :congruence)