• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
          • Slow-array-warning
          • Compress1
          • Aset1
          • Aref1
          • Flush-compress
          • Aset2
          • Compress2
          • Header
          • Aref2
            • Maximum-length
            • Dimensions
            • Default
            • Aset1-trusted
            • Arrays-example
            • Array2p
            • Array1p
            • Maybe-flush-and-compress1
          • Characters
          • Time$
          • Loop$-primer
          • Fast-alists
          • Defmacro
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • System-attachments
          • Developers-guide
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Irrelevant-formals
          • Efficiency
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Defmacro-untouchable
          • Primitive
          • <<
          • Revert-world
          • Set-duplicate-keys-action
          • Unmemoize
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Defopen
          • Sleep
        • Start-here
        • Real
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Arrays
    • ACL2-built-ins

    Aref2

    Access the elements of a 2-dimensional array

    Example Form:
    (aref2 'delta1 a i j)
    
    General Form:
    (aref2 name alist i j)

    where name is a symbol, alist is a 2-dimensional array and i and j are legal indices into alist. This function returns the value associated with (i . j) in alist, or else the default value of the array. See arrays for details.

    This function executes in virtually constant time if alist is in fact the ``semantic value'' associated with name (see arrays). When it is not, aref2 must do a linear search through alist. In that case the correct answer is returned but a slow array comment is printed to the comment window. See slow-array-warning.

    Function: aref2

    (defun
         aref2 (name l i j)
         (declare (xargs :guard (and (array2p name l)
                                     (integerp i)
                                     (>= i 0)
                                     (< i (car (dimensions name l)))
                                     (integerp j)
                                     (>= j 0)
                                     (< j (cadr (dimensions name l))))))
         (let ((x (assoc2 i j l)))
              (cond ((null x) (default name l))
                    (t (cdr x)))))