• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
      • Axe
      • Execloader
        • Elf-reader
        • Mach-o-reader
          • Read-load_commands
          • Read-section_data_sz_structures
          • Mach-o-section-header
          • Mach-o-header
            • Mach-o-header-fix
              • Make-mach-o-header
              • Mach-o-header-equiv
              • Mach-o-header-p
              • Change-mach-o-header
              • Mach-o-header->reserved
              • Mach-o-header->sizeofcmds
              • Mach-o-header->filetype
              • Mach-o-header->cputype
              • Mach-o-header->cpusubtype
              • Mach-o-header->ncmds
              • Mach-o-header->magic
              • Mach-o-header->flags
            • Populate-mach-o-contents
            • Good-mach-o-p
            • Fill-data-segment-bytes
            • Fill-text-text-section-bytes
            • Fill-text-segment-bytes
            • Fill-text-cstring-section-bytes
            • Fill-text-const-section-bytes
            • Fill-data-dyld-section-bytes
            • Fill-data-data-section-bytes
            • Fill-data-const-section-bytes
            • Fill-data-common-section-bytes
            • Fill-data-bss-section-bytes
            • Read-mach_header
            • Populate-mach-o
            • Mach-o-section-headers
          • Merge-first-split-bytes
          • Split-bytes
          • Take-till-zero
          • Charlist->bytes
          • Merge-bytes
          • Bytes->charlist
          • String->bytes
          • Bytes->string
      • Math
      • Testing-utilities
    • Mach-o-header

    Mach-o-header-fix

    Fixing function for mach-o-header structures.

    Signature
    (mach-o-header-fix x) → new-x
    Arguments
    x — Guard (mach-o-header-p x).
    Returns
    new-x — Type (mach-o-header-p new-x).

    Definitions and Theorems

    Function: mach-o-header-fix$inline

    (defun mach-o-header-fix$inline (x)
     (declare (xargs :guard (mach-o-header-p x)))
     (let ((__function__ 'mach-o-header-fix))
      (declare (ignorable __function__))
      (mbe
         :logic
         (b* ((magic (nfix (cdr (std::da-nth 0 x))))
              (cputype (nfix (cdr (std::da-nth 1 x))))
              (cpusubtype (nfix (cdr (std::da-nth 2 x))))
              (filetype (nfix (cdr (std::da-nth 3 x))))
              (ncmds (nfix (cdr (std::da-nth 4 x))))
              (sizeofcmds (nfix (cdr (std::da-nth 5 x))))
              (flags (nfix (cdr (std::da-nth 6 x))))
              (reserved (acl2::maybe-natp-fix (cdr (std::da-nth 7 x)))))
           (list (cons 'magic magic)
                 (cons 'cputype cputype)
                 (cons 'cpusubtype cpusubtype)
                 (cons 'filetype filetype)
                 (cons 'ncmds ncmds)
                 (cons 'sizeofcmds sizeofcmds)
                 (cons 'flags flags)
                 (cons 'reserved reserved)))
         :exec x)))

    Theorem: mach-o-header-p-of-mach-o-header-fix

    (defthm mach-o-header-p-of-mach-o-header-fix
      (b* ((new-x (mach-o-header-fix$inline x)))
        (mach-o-header-p new-x))
      :rule-classes :rewrite)

    Theorem: mach-o-header-fix-when-mach-o-header-p

    (defthm mach-o-header-fix-when-mach-o-header-p
      (implies (mach-o-header-p x)
               (equal (mach-o-header-fix x) x)))

    Function: mach-o-header-equiv$inline

    (defun mach-o-header-equiv$inline (x y)
      (declare (xargs :guard (and (mach-o-header-p x)
                                  (mach-o-header-p y))))
      (equal (mach-o-header-fix x)
             (mach-o-header-fix y)))

    Theorem: mach-o-header-equiv-is-an-equivalence

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

    Theorem: mach-o-header-equiv-implies-equal-mach-o-header-fix-1

    (defthm mach-o-header-equiv-implies-equal-mach-o-header-fix-1
      (implies (mach-o-header-equiv x x-equiv)
               (equal (mach-o-header-fix x)
                      (mach-o-header-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: mach-o-header-fix-under-mach-o-header-equiv

    (defthm mach-o-header-fix-under-mach-o-header-equiv
      (mach-o-header-equiv (mach-o-header-fix x)
                           x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-mach-o-header-fix-1-forward-to-mach-o-header-equiv

    (defthm equal-of-mach-o-header-fix-1-forward-to-mach-o-header-equiv
      (implies (equal (mach-o-header-fix x) y)
               (mach-o-header-equiv x y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-mach-o-header-fix-2-forward-to-mach-o-header-equiv

    (defthm equal-of-mach-o-header-fix-2-forward-to-mach-o-header-equiv
      (implies (equal x (mach-o-header-fix y))
               (mach-o-header-equiv x y))
      :rule-classes :forward-chaining)

    Theorem: mach-o-header-equiv-of-mach-o-header-fix-1-forward

    (defthm mach-o-header-equiv-of-mach-o-header-fix-1-forward
      (implies (mach-o-header-equiv (mach-o-header-fix x)
                                    y)
               (mach-o-header-equiv x y))
      :rule-classes :forward-chaining)

    Theorem: mach-o-header-equiv-of-mach-o-header-fix-2-forward

    (defthm mach-o-header-equiv-of-mach-o-header-fix-2-forward
      (implies (mach-o-header-equiv x (mach-o-header-fix y))
               (mach-o-header-equiv x y))
      :rule-classes :forward-chaining)