• 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
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • 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
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
                • Execution
                • Values
                • Dynamic-environments
                • Arithmetic-operations
                • Curve-parameterization
                • Shift-operations
                • Errors
                • Value-expressions
                • Locations
                • Input-execution
                • Edwards-bls12-generator
                • Equality-operations
                • Logical-operations
                • Program-execution
                • Ordering-operations
                • Bitwise-operations
                • Literal-evaluation
                • Type-maps-for-struct-components
                • Output-execution
                • Tuple-operations
                  • Op-tuple-write
                  • Op-tuple-read
                    • Op-tuple-make
                  • Struct-operations
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Tuple-operations

    Op-tuple-read

    Leo tuple reading operation.

    Signature
    (op-tuple-read tupval index) → result
    Arguments
    tupval — Guard (valuep tupval).
    index — Guard (natp index).
    Returns
    result — Type (value-resultp result).

    This takes a value and a natural number index; the latter must be a numeral in the syntax. The value must be a tuple, otherwise it is an error. Furthermore, the index must be below the tuple length; tuples are zero-indexed.

    Definitions and Theorems

    Function: op-tuple-read

    (defun op-tuple-read (tupval index)
      (declare (xargs :guard (and (valuep tupval) (natp index))))
      (let ((__function__ 'op-tuple-read))
        (declare (ignorable __function__))
        (if (and (value-case tupval :tuple)
                 (< (nfix index)
                    (len (value-tuple->components tupval))))
            (nth (nfix index)
                 (value-tuple->components tupval))
          (reserrf (list :op-tuple-read (value-fix tupval)
                         (nfix index))))))

    Theorem: value-resultp-of-op-tuple-read

    (defthm value-resultp-of-op-tuple-read
      (b* ((result (op-tuple-read tupval index)))
        (value-resultp result))
      :rule-classes :rewrite)

    Theorem: op-tuple-read-of-value-fix-tupval

    (defthm op-tuple-read-of-value-fix-tupval
      (equal (op-tuple-read (value-fix tupval) index)
             (op-tuple-read tupval index)))

    Theorem: op-tuple-read-value-equiv-congruence-on-tupval

    (defthm op-tuple-read-value-equiv-congruence-on-tupval
      (implies (value-equiv tupval tupval-equiv)
               (equal (op-tuple-read tupval index)
                      (op-tuple-read tupval-equiv index)))
      :rule-classes :congruence)

    Theorem: op-tuple-read-of-nfix-index

    (defthm op-tuple-read-of-nfix-index
      (equal (op-tuple-read tupval (nfix index))
             (op-tuple-read tupval index)))

    Theorem: op-tuple-read-nat-equiv-congruence-on-index

    (defthm op-tuple-read-nat-equiv-congruence-on-index
      (implies (acl2::nat-equiv index index-equiv)
               (equal (op-tuple-read tupval index)
                      (op-tuple-read tupval index-equiv)))
      :rule-classes :congruence)