• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
        • Syntax-for-tools
        • Atc
        • Language
          • Abstract-syntax
          • Integer-ranges
          • Implementation-environments
          • Dynamic-semantics
          • Static-semantics
          • Grammar
          • Integer-formats
          • Types
          • Portable-ascii-identifiers
          • Values
          • Integer-operations
          • Computation-states
          • Object-designators
          • Operations
          • Errors
          • Tag-environments
          • Function-environments
          • Character-sets
          • Flexible-array-member-removal
          • Arithmetic-operations
          • Pointer-operations
          • Bytes
          • Keywords
          • Real-operations
          • Array-operations
          • Scalar-operations
          • Structure-operations
            • Value-struct-write
            • Value-struct-read
          • Representation
          • Transformation-tools
          • Insertion-sort
          • Pack
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Structure-operations

    Value-struct-read

    Read a member of a structure.

    Signature
    (value-struct-read name struct) → val
    Arguments
    name — Guard (identp name).
    struct — Guard (valuep struct).
    Returns
    val — Type (value-resultp val).

    We look up the members in order; given that the members have distinct names (see value), the search order is immaterial.

    Definitions and Theorems

    Function: value-struct-read-aux

    (defun value-struct-read-aux (name members)
      (declare (xargs :guard (and (identp name)
                                  (member-value-listp members))))
      (let ((__function__ 'value-struct-read-aux))
        (declare (ignorable __function__))
        (b* (((when (endp members))
              (error (list :member-not-found (ident-fix name))))
             ((member-value member) (car members))
             ((when (equal member.name (ident-fix name)))
              member.value))
          (value-struct-read-aux name (cdr members)))))

    Theorem: value-resultp-of-value-struct-read-aux

    (defthm value-resultp-of-value-struct-read-aux
      (b* ((val (value-struct-read-aux name members)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: value-struct-read-aux-when-member-type-lookup

    (defthm value-struct-read-aux-when-member-type-lookup
      (implies (equal memtypes
                      (member-types-of-member-values memvals))
               (b* ((type (member-type-lookup name memtypes))
                    (val (value-struct-read-aux name memvals)))
                 (implies (typep type)
                          (and (valuep val)
                               (equal (type-of-value val) type))))))

    Theorem: value-struct-read-aux-of-ident-fix-name

    (defthm value-struct-read-aux-of-ident-fix-name
      (equal (value-struct-read-aux (ident-fix name)
                                    members)
             (value-struct-read-aux name members)))

    Theorem: value-struct-read-aux-ident-equiv-congruence-on-name

    (defthm value-struct-read-aux-ident-equiv-congruence-on-name
      (implies (ident-equiv name name-equiv)
               (equal (value-struct-read-aux name members)
                      (value-struct-read-aux name-equiv members)))
      :rule-classes :congruence)

    Theorem: value-struct-read-aux-of-member-value-list-fix-members

    (defthm value-struct-read-aux-of-member-value-list-fix-members
     (equal (value-struct-read-aux name (member-value-list-fix members))
            (value-struct-read-aux name members)))

    Theorem: value-struct-read-aux-member-value-list-equiv-congruence-on-members

    (defthm
     value-struct-read-aux-member-value-list-equiv-congruence-on-members
     (implies (member-value-list-equiv members members-equiv)
              (equal (value-struct-read-aux name members)
                     (value-struct-read-aux name members-equiv)))
     :rule-classes :congruence)

    Function: value-struct-read

    (defun value-struct-read (name struct)
      (declare (xargs :guard (and (identp name) (valuep struct))))
      (declare (xargs :guard (value-case struct :struct)))
      (let ((__function__ 'value-struct-read))
        (declare (ignorable __function__))
        (value-struct-read-aux name (value-struct->members struct))))

    Theorem: value-resultp-of-value-struct-read

    (defthm value-resultp-of-value-struct-read
      (b* ((val (value-struct-read name struct)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: value-struct-read-of-ident-fix-name

    (defthm value-struct-read-of-ident-fix-name
      (equal (value-struct-read (ident-fix name)
                                struct)
             (value-struct-read name struct)))

    Theorem: value-struct-read-ident-equiv-congruence-on-name

    (defthm value-struct-read-ident-equiv-congruence-on-name
      (implies (ident-equiv name name-equiv)
               (equal (value-struct-read name struct)
                      (value-struct-read name-equiv struct)))
      :rule-classes :congruence)

    Theorem: value-struct-read-of-value-fix-struct

    (defthm value-struct-read-of-value-fix-struct
      (equal (value-struct-read name (value-fix struct))
             (value-struct-read name struct)))

    Theorem: value-struct-read-value-equiv-congruence-on-struct

    (defthm value-struct-read-value-equiv-congruence-on-struct
      (implies (value-equiv struct struct-equiv)
               (equal (value-struct-read name struct)
                      (value-struct-read name struct-equiv)))
      :rule-classes :congruence)