Decompose an expression into a list of expressions of given length.
(decompose-expression expr n) → exprs
If
The idea is that
Function:
(defun decompose-expression-aux (i n expr) (declare (xargs :guard (and (natp i) (natp n) (expressionp expr)))) (let ((__function__ 'decompose-expression-aux)) (declare (ignorable __function__)) (b* ((i (nfix i)) (n (nfix n))) (if (>= i n) nil (cons (make-expression-component :multi expr :index i) (decompose-expression-aux (1+ i) n expr))))))
Theorem:
(defthm expression-listp-of-decompose-expression-aux (b* ((exprs (decompose-expression-aux i n expr))) (expression-listp exprs)) :rule-classes :rewrite)
Theorem:
(defthm len-of-decompose-expression-aux (b* ((?exprs (decompose-expression-aux i n expr))) (equal (len exprs) (nfix (- (nfix n) (nfix i))))))
Theorem:
(defthm decompose-expression-aux-of-nfix-i (equal (decompose-expression-aux (nfix i) n expr) (decompose-expression-aux i n expr)))
Theorem:
(defthm decompose-expression-aux-nat-equiv-congruence-on-i (implies (nat-equiv i i-equiv) (equal (decompose-expression-aux i n expr) (decompose-expression-aux i-equiv n expr))) :rule-classes :congruence)
Theorem:
(defthm decompose-expression-aux-of-nfix-n (equal (decompose-expression-aux i (nfix n) expr) (decompose-expression-aux i n expr)))
Theorem:
(defthm decompose-expression-aux-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (decompose-expression-aux i n expr) (decompose-expression-aux i n-equiv expr))) :rule-classes :congruence)
Theorem:
(defthm decompose-expression-aux-of-expression-fix-expr (equal (decompose-expression-aux i n (expression-fix expr)) (decompose-expression-aux i n expr)))
Theorem:
(defthm decompose-expression-aux-expression-equiv-congruence-on-expr (implies (expression-equiv expr expr-equiv) (equal (decompose-expression-aux i n expr) (decompose-expression-aux i n expr-equiv))) :rule-classes :congruence)
Function:
(defun decompose-expression (expr n) (declare (xargs :guard (and (expressionp expr) (posp n)))) (let ((__function__ 'decompose-expression)) (declare (ignorable __function__)) (b* ((n (pos-fix n))) (if (= n 1) (list (expression-fix expr)) (decompose-expression-aux 0 n expr)))))
Theorem:
(defthm expression-listp-of-decompose-expression (b* ((exprs (decompose-expression expr n))) (expression-listp exprs)) :rule-classes :rewrite)
Theorem:
(defthm len-of-decompose-expression (b* ((?exprs (decompose-expression expr n))) (equal (len exprs) (pos-fix n))))
Theorem:
(defthm decompose-expression-of-expression-fix-expr (equal (decompose-expression (expression-fix expr) n) (decompose-expression expr n)))
Theorem:
(defthm decompose-expression-expression-equiv-congruence-on-expr (implies (expression-equiv expr expr-equiv) (equal (decompose-expression expr n) (decompose-expression expr-equiv n))) :rule-classes :congruence)
Theorem:
(defthm decompose-expression-of-pos-fix-n (equal (decompose-expression expr (pos-fix n)) (decompose-expression expr n)))
Theorem:
(defthm decompose-expression-pos-equiv-congruence-on-n (implies (pos-equiv n n-equiv) (equal (decompose-expression expr n) (decompose-expression expr n-equiv))) :rule-classes :congruence)