• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • 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
        • C
          • Syntax-for-tools
            • Formalized-subset
            • Mapping-to-language-definition
            • Input-files
            • Compilation-database
            • Printer
            • Output-files
            • Abstract-syntax-operations
            • Implementation-environments
              • Ienv
                • Ienvp
                • Ienv-fix
                  • Make-ienv
                  • Ienv->short-bytes
                  • Ienv->llong-bytes
                  • Ienv-equiv
                  • Ienv->long-bytes
                  • Ienv->int-bytes
                  • Ienv->plain-char-signedp
                  • Change-ienv
                  • Ienv->version
                • Ldm-ienv
                • Ienv-ushort-rangep
                • Ienv-ulong-rangep
                • Ienv-ullong-rangep
                • Ienv-uchar-rangep
                • Ienv-sshort-rangep
                • Ienv-slong-rangep
                • Ienv-sllong-rangep
                • Ienv-sint-rangep
                • Ienv-schar-rangep
                • Ienv-uint-rangep
                • Ienv-char-rangep
                • Ienv->uchar-max
                • Ienv->schar-min
                • Ienv->schar-max
                • Ienv->ushort-max
                • Ienv->ulong-max
                • Ienv->ullong-max
                • Ienv->sshort-max
                • Ienv->slong-max
                • Ienv->sllong-max
                • Ienv->uint-max
                • Ienv->sint-max
                • Ienv->sshort-min
                • Ienv->slong-min
                • Ienv->sllong-min
                • Ienv->sint-min
                • Ienv->char-min
                • Ienv->char-max
                • Ienv->std
                • Ienv->gcc
                • Ienv-default
              • Abstract-syntax
              • Concrete-syntax
              • Disambiguation
              • Validation
              • Gcc-builtins
              • Preprocessing
              • Parsing
            • Atc
            • Transformation-tools
            • Language
            • Representation
            • Insertion-sort
            • Pack
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Ienv

    Ienv-fix

    Fixing function for ienv structures.

    Signature
    (ienv-fix x) → new-x
    Arguments
    x — Guard (ienvp x).
    Returns
    new-x — Type (ienvp new-x).

    Definitions and Theorems

    Function: ienv-fix$inline

    (defun ienv-fix$inline (x)
      (declare (xargs :guard (ienvp x)))
      (mbe :logic
           (b* ((version (c::version-fix (cdr (std::da-nth 0 x))))
                (short-bytes (pos-fix (cdr (std::da-nth 1 x))))
                (int-bytes (pos-fix (cdr (std::da-nth 2 x))))
                (long-bytes (pos-fix (cdr (std::da-nth 3 x))))
                (llong-bytes (pos-fix (cdr (std::da-nth 4 x))))
                (plain-char-signedp (bool-fix (cdr (std::da-nth 5 x)))))
             (let ((short-bytes (if (and (<= short-bytes int-bytes)
                                         (<= int-bytes long-bytes)
                                         (<= long-bytes llong-bytes)
                                         (<= 2 short-bytes)
                                         (<= 2 int-bytes)
                                         (<= 4 long-bytes)
                                         (<= 8 llong-bytes))
                                    short-bytes
                                  2))
                   (int-bytes (if (and (<= short-bytes int-bytes)
                                       (<= int-bytes long-bytes)
                                       (<= long-bytes llong-bytes)
                                       (<= 2 short-bytes)
                                       (<= 2 int-bytes)
                                       (<= 4 long-bytes)
                                       (<= 8 llong-bytes))
                                  int-bytes
                                2))
                   (long-bytes (if (and (<= short-bytes int-bytes)
                                        (<= int-bytes long-bytes)
                                        (<= long-bytes llong-bytes)
                                        (<= 2 short-bytes)
                                        (<= 2 int-bytes)
                                        (<= 4 long-bytes)
                                        (<= 8 llong-bytes))
                                   long-bytes
                                 4))
                   (llong-bytes (if (and (<= short-bytes int-bytes)
                                         (<= int-bytes long-bytes)
                                         (<= long-bytes llong-bytes)
                                         (<= 2 short-bytes)
                                         (<= 2 int-bytes)
                                         (<= 4 long-bytes)
                                         (<= 8 llong-bytes))
                                    llong-bytes
                                  8)))
               (list (cons 'version version)
                     (cons 'short-bytes short-bytes)
                     (cons 'int-bytes int-bytes)
                     (cons 'long-bytes long-bytes)
                     (cons 'llong-bytes llong-bytes)
                     (cons 'plain-char-signedp
                           plain-char-signedp))))
           :exec x))

    Theorem: ienvp-of-ienv-fix

    (defthm ienvp-of-ienv-fix
      (b* ((new-x (ienv-fix$inline x)))
        (ienvp new-x))
      :rule-classes :rewrite)

    Theorem: ienv-fix-when-ienvp

    (defthm ienv-fix-when-ienvp
      (implies (ienvp x)
               (equal (ienv-fix x) x)))

    Function: ienv-equiv$inline

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

    Theorem: ienv-equiv-is-an-equivalence

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

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

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

    Theorem: ienv-fix-under-ienv-equiv

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

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

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

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

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

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

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

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

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

    Theorem: ienv-fix$inline-of-ienv-fix-x

    (defthm ienv-fix$inline-of-ienv-fix-x
      (equal (ienv-fix$inline (ienv-fix x))
             (ienv-fix$inline x)))

    Theorem: ienv-fix$inline-ienv-equiv-congruence-on-x

    (defthm ienv-fix$inline-ienv-equiv-congruence-on-x
      (implies (ienv-equiv x x-equiv)
               (equal (ienv-fix$inline x)
                      (ienv-fix$inline x-equiv)))
      :rule-classes :congruence)