Check if a let binding may represent an array write.
(atc-check-array-write var val) → (mv erp yes/no fn sub elem elem-type)
An array write, i.e. an assignment to an array element, is represented by a let binding of the form
(let ((<arr> (<type>-array-write <arr> <sub> <elem>))) ...)
where
Function:
(defun atc-check-array-write (var val) (declare (xargs :guard (and (symbolp var) (pseudo-termp val)))) (let ((__function__ 'atc-check-array-write)) (declare (ignorable __function__)) (b* (((reterr) nil nil nil nil (irr-type)) ((acl2::fun (no)) (retok nil nil nil nil (irr-type))) ((mv okp fn args) (fty-check-fn-call val)) ((unless okp) (no)) ((mv okp fixtype array write) (atc-check-symbol-3part fn)) (elem-type (fixtype-to-integer-type fixtype)) ((unless (and okp elem-type (eq array 'array) (eq write 'write))) (no)) ((unless (equal (symbol-package-name fn) "C")) (reterr (msg "Invalid function ~x0 encountered: ~ it has the form of an array write, ~ but it is not in the \"C\" package." fn))) ((unless (list-lenp 3 args)) (reterr (raise "Internal error: ~x0 not applied to 3 arguments." fn))) ((unless (equal (first args) var)) (reterr (raise "Internal error: ~x0 is not applied to the variable ~x1." fn var))) (sub (second args)) (elem (third args))) (retok t fn sub elem elem-type))))
Theorem:
(defthm booleanp-of-atc-check-array-write.yes/no (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm symbolp-of-atc-check-array-write.fn (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (symbolp fn)) :rule-classes :rewrite)
Theorem:
(defthm pseudo-termp-of-atc-check-array-write.sub (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (pseudo-termp sub)) :rule-classes :rewrite)
Theorem:
(defthm pseudo-termp-of-atc-check-array-write.elem (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (pseudo-termp elem)) :rule-classes :rewrite)
Theorem:
(defthm typep-of-atc-check-array-write.elem-type (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (typep elem-type)) :rule-classes :rewrite)
Theorem:
(defthm pseudo-term-count-of-atc-check-array-write-sub (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (implies yes/no (< (pseudo-term-count sub) (pseudo-term-count val)))) :rule-classes :linear)
Theorem:
(defthm pseudo-term-count-of-atc-check-array-write-elem (b* (((mv acl2::?erp ?yes/no ?fn ?sub ?elem ?elem-type) (atc-check-array-write var val))) (implies yes/no (< (pseudo-term-count elem) (pseudo-term-count val)))) :rule-classes :linear)