Fixing function for instr structures.
Function:
(defun instr-fix$inline (x) (declare (xargs :guard (instrp x))) (let ((__function__ 'instr-fix)) (declare (ignorable __function__)) (mbe :logic (case (instr-kind x) (:op-imm (b* ((funct (op-imm-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte12-fix (std::da-nth 3 (cdr x))))) (cons :op-imm (list funct rd rs1 imm)))) (:op-imms32 (b* ((funct (op-imms-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte5-fix (std::da-nth 3 (cdr x))))) (cons :op-imms32 (list funct rd rs1 imm)))) (:op-imms64 (b* ((funct (op-imms-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte6-fix (std::da-nth 3 (cdr x))))) (cons :op-imms64 (list funct rd rs1 imm)))) (:op-imm-32 (b* ((funct (op-imm-32-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte12-fix (std::da-nth 3 (cdr x))))) (cons :op-imm-32 (list funct rd rs1 imm)))) (:op-imms-32 (b* ((funct (op-imms-32-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte5-fix (std::da-nth 3 (cdr x))))) (cons :op-imms-32 (list funct rd rs1 imm)))) (:lui (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x)))) (imm (ubyte20-fix (std::da-nth 1 (cdr x))))) (cons :lui (list rd imm)))) (:auipc (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x)))) (imm (ubyte20-fix (std::da-nth 1 (cdr x))))) (cons :auipc (list rd imm)))) (:op (b* ((funct (op-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (rs2 (ubyte5-fix (std::da-nth 3 (cdr x))))) (cons :op (list funct rd rs1 rs2)))) (:op-32 (b* ((funct (op-32-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (rs2 (ubyte5-fix (std::da-nth 3 (cdr x))))) (cons :op-32 (list funct rd rs1 rs2)))) (:jal (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x)))) (imm (ubyte20-fix (std::da-nth 1 (cdr x))))) (cons :jal (list rd imm)))) (:jalr (b* ((rd (ubyte5-fix (std::da-nth 0 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 1 (cdr x)))) (imm (ubyte12-fix (std::da-nth 2 (cdr x))))) (cons :jalr (list rd rs1 imm)))) (:branch (b* ((funct (branch-funct-fix (std::da-nth 0 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs2 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte12-fix (std::da-nth 3 (cdr x))))) (cons :branch (list funct rs1 rs2 imm)))) (:load (b* ((funct (load-funct-fix (std::da-nth 0 (cdr x)))) (rd (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte12-fix (std::da-nth 3 (cdr x))))) (cons :load (list funct rd rs1 imm)))) (:store (b* ((funct (store-funct-fix (std::da-nth 0 (cdr x)))) (rs1 (ubyte5-fix (std::da-nth 1 (cdr x)))) (rs2 (ubyte5-fix (std::da-nth 2 (cdr x)))) (imm (ubyte12-fix (std::da-nth 3 (cdr x))))) (cons :store (list funct rs1 rs2 imm))))) :exec x)))
Theorem:
(defthm instrp-of-instr-fix (b* ((new-x (instr-fix$inline x))) (instrp new-x)) :rule-classes :rewrite)
Theorem:
(defthm instr-fix-when-instrp (implies (instrp x) (equal (instr-fix x) x)))
Function:
(defun instr-equiv$inline (acl2::x acl2::y) (declare (xargs :guard (and (instrp acl2::x) (instrp acl2::y)))) (equal (instr-fix acl2::x) (instr-fix acl2::y)))
Theorem:
(defthm instr-equiv-is-an-equivalence (and (booleanp (instr-equiv x y)) (instr-equiv x x) (implies (instr-equiv x y) (instr-equiv y x)) (implies (and (instr-equiv x y) (instr-equiv y z)) (instr-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm instr-equiv-implies-equal-instr-fix-1 (implies (instr-equiv acl2::x x-equiv) (equal (instr-fix acl2::x) (instr-fix x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm instr-fix-under-instr-equiv (instr-equiv (instr-fix acl2::x) acl2::x) :rule-classes (:rewrite :rewrite-quoted-constant))
Theorem:
(defthm equal-of-instr-fix-1-forward-to-instr-equiv (implies (equal (instr-fix acl2::x) acl2::y) (instr-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm equal-of-instr-fix-2-forward-to-instr-equiv (implies (equal acl2::x (instr-fix acl2::y)) (instr-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm instr-equiv-of-instr-fix-1-forward (implies (instr-equiv (instr-fix acl2::x) acl2::y) (instr-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm instr-equiv-of-instr-fix-2-forward (implies (instr-equiv acl2::x (instr-fix acl2::y)) (instr-equiv acl2::x acl2::y)) :rule-classes :forward-chaining)
Theorem:
(defthm instr-kind$inline-of-instr-fix-x (equal (instr-kind$inline (instr-fix x)) (instr-kind$inline x)))
Theorem:
(defthm instr-kind$inline-instr-equiv-congruence-on-x (implies (instr-equiv x x-equiv) (equal (instr-kind$inline x) (instr-kind$inline x-equiv))) :rule-classes :congruence)
Theorem:
(defthm consp-of-instr-fix (consp (instr-fix x)) :rule-classes :type-prescription)