• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
          • Primitive-functions
          • Translated-terms
          • Values
          • Evaluation
          • Program-equivalence
          • Functions
          • Packages
          • Programs
          • Interpreter
          • Evaluation-states
            • Eval-state
            • Frame
            • Binding
            • Stack
              • Stack-fix
                • Stack-equiv
                • Stackp
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Stack

    Stack-fix

    (stack-fix x) is a usual ACL2::fty list fixing function.

    Signature
    (stack-fix x) → fty::newx
    Arguments
    x — Guard (stackp x).
    Returns
    fty::newx — Type (stackp fty::newx).

    In the logic, we apply frame-fix to each member of the x. In the execution, none of that is actually necessary and this is just an inlined identity function.

    Definitions and Theorems

    Function: stack-fix$inline

    (defun stack-fix$inline (x)
      (declare (xargs :guard (stackp x)))
      (let ((__function__ 'stack-fix))
        (declare (ignorable __function__))
        (mbe :logic
             (if (atom x)
                 nil
               (cons (frame-fix (car x))
                     (stack-fix (cdr x))))
             :exec x)))

    Theorem: stackp-of-stack-fix

    (defthm stackp-of-stack-fix
      (b* ((fty::newx (stack-fix$inline x)))
        (stackp fty::newx))
      :rule-classes :rewrite)

    Theorem: stack-fix-when-stackp

    (defthm stack-fix-when-stackp
      (implies (stackp x)
               (equal (stack-fix x) x)))

    Function: stack-equiv$inline

    (defun stack-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (stackp acl2::x)
                                  (stackp acl2::y))))
      (equal (stack-fix acl2::x)
             (stack-fix acl2::y)))

    Theorem: stack-equiv-is-an-equivalence

    (defthm stack-equiv-is-an-equivalence
      (and (booleanp (stack-equiv x y))
           (stack-equiv x x)
           (implies (stack-equiv x y)
                    (stack-equiv y x))
           (implies (and (stack-equiv x y)
                         (stack-equiv y z))
                    (stack-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: stack-equiv-implies-equal-stack-fix-1

    (defthm stack-equiv-implies-equal-stack-fix-1
      (implies (stack-equiv acl2::x x-equiv)
               (equal (stack-fix acl2::x)
                      (stack-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: stack-fix-under-stack-equiv

    (defthm stack-fix-under-stack-equiv
      (stack-equiv (stack-fix acl2::x)
                   acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-stack-fix-1-forward-to-stack-equiv

    (defthm equal-of-stack-fix-1-forward-to-stack-equiv
      (implies (equal (stack-fix acl2::x) acl2::y)
               (stack-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-stack-fix-2-forward-to-stack-equiv

    (defthm equal-of-stack-fix-2-forward-to-stack-equiv
      (implies (equal acl2::x (stack-fix acl2::y))
               (stack-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: stack-equiv-of-stack-fix-1-forward

    (defthm stack-equiv-of-stack-fix-1-forward
      (implies (stack-equiv (stack-fix acl2::x)
                            acl2::y)
               (stack-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: stack-equiv-of-stack-fix-2-forward

    (defthm stack-equiv-of-stack-fix-2-forward
      (implies (stack-equiv acl2::x (stack-fix acl2::y))
               (stack-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: car-of-stack-fix-x-under-frame-equiv

    (defthm car-of-stack-fix-x-under-frame-equiv
      (frame-equiv (car (stack-fix acl2::x))
                   (car acl2::x)))

    Theorem: car-stack-equiv-congruence-on-x-under-frame-equiv

    (defthm car-stack-equiv-congruence-on-x-under-frame-equiv
      (implies (stack-equiv acl2::x x-equiv)
               (frame-equiv (car acl2::x)
                            (car x-equiv)))
      :rule-classes :congruence)

    Theorem: cdr-of-stack-fix-x-under-stack-equiv

    (defthm cdr-of-stack-fix-x-under-stack-equiv
      (stack-equiv (cdr (stack-fix acl2::x))
                   (cdr acl2::x)))

    Theorem: cdr-stack-equiv-congruence-on-x-under-stack-equiv

    (defthm cdr-stack-equiv-congruence-on-x-under-stack-equiv
      (implies (stack-equiv acl2::x x-equiv)
               (stack-equiv (cdr acl2::x)
                            (cdr x-equiv)))
      :rule-classes :congruence)

    Theorem: cons-of-frame-fix-x-under-stack-equiv

    (defthm cons-of-frame-fix-x-under-stack-equiv
      (stack-equiv (cons (frame-fix acl2::x) acl2::y)
                   (cons acl2::x acl2::y)))

    Theorem: cons-frame-equiv-congruence-on-x-under-stack-equiv

    (defthm cons-frame-equiv-congruence-on-x-under-stack-equiv
      (implies (frame-equiv acl2::x x-equiv)
               (stack-equiv (cons acl2::x acl2::y)
                            (cons x-equiv acl2::y)))
      :rule-classes :congruence)

    Theorem: cons-of-stack-fix-y-under-stack-equiv

    (defthm cons-of-stack-fix-y-under-stack-equiv
      (stack-equiv (cons acl2::x (stack-fix acl2::y))
                   (cons acl2::x acl2::y)))

    Theorem: cons-stack-equiv-congruence-on-y-under-stack-equiv

    (defthm cons-stack-equiv-congruence-on-y-under-stack-equiv
      (implies (stack-equiv acl2::y y-equiv)
               (stack-equiv (cons acl2::x acl2::y)
                            (cons acl2::x y-equiv)))
      :rule-classes :congruence)

    Theorem: consp-of-stack-fix

    (defthm consp-of-stack-fix
      (equal (consp (stack-fix acl2::x))
             (consp acl2::x)))

    Theorem: stack-fix-under-iff

    (defthm stack-fix-under-iff
      (iff (stack-fix acl2::x)
           (consp acl2::x)))

    Theorem: stack-fix-of-cons

    (defthm stack-fix-of-cons
      (equal (stack-fix (cons a x))
             (cons (frame-fix a) (stack-fix x))))

    Theorem: len-of-stack-fix

    (defthm len-of-stack-fix
      (equal (len (stack-fix acl2::x))
             (len acl2::x)))

    Theorem: stack-fix-of-append

    (defthm stack-fix-of-append
      (equal (stack-fix (append std::a std::b))
             (append (stack-fix std::a)
                     (stack-fix std::b))))

    Theorem: stack-fix-of-repeat

    (defthm stack-fix-of-repeat
      (equal (stack-fix (repeat acl2::n acl2::x))
             (repeat acl2::n (frame-fix acl2::x))))

    Theorem: list-equiv-refines-stack-equiv

    (defthm list-equiv-refines-stack-equiv
      (implies (list-equiv acl2::x acl2::y)
               (stack-equiv acl2::x acl2::y))
      :rule-classes :refinement)

    Theorem: nth-of-stack-fix

    (defthm nth-of-stack-fix
      (equal (nth acl2::n (stack-fix acl2::x))
             (if (< (nfix acl2::n) (len acl2::x))
                 (frame-fix (nth acl2::n acl2::x))
               nil)))

    Theorem: stack-equiv-implies-stack-equiv-append-1

    (defthm stack-equiv-implies-stack-equiv-append-1
      (implies (stack-equiv acl2::x fty::x-equiv)
               (stack-equiv (append acl2::x acl2::y)
                            (append fty::x-equiv acl2::y)))
      :rule-classes (:congruence))

    Theorem: stack-equiv-implies-stack-equiv-append-2

    (defthm stack-equiv-implies-stack-equiv-append-2
      (implies (stack-equiv acl2::y fty::y-equiv)
               (stack-equiv (append acl2::x acl2::y)
                            (append acl2::x fty::y-equiv)))
      :rule-classes (:congruence))

    Theorem: stack-equiv-implies-stack-equiv-nthcdr-2

    (defthm stack-equiv-implies-stack-equiv-nthcdr-2
      (implies (stack-equiv acl2::l l-equiv)
               (stack-equiv (nthcdr acl2::n acl2::l)
                            (nthcdr acl2::n l-equiv)))
      :rule-classes (:congruence))

    Theorem: stack-equiv-implies-stack-equiv-take-2

    (defthm stack-equiv-implies-stack-equiv-take-2
      (implies (stack-equiv acl2::l l-equiv)
               (stack-equiv (take acl2::n acl2::l)
                            (take acl2::n l-equiv)))
      :rule-classes (:congruence))