• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
              • Atj-input-processing
              • Atj-java-pretty-printer
              • Atj-code-generation
                • Atj-gen-test-method
                • Atj-shallow-code-generation
                • Atj-common-code-generation
                • Atj-shallow-quoted-constant-generation
                  • Atj-qconstants-p
                  • Atj-gen-shallow-symbol
                  • Atj-gen-shallow-cons-field-name
                  • Atj-gen-shallow-symbol-field-name
                  • Atj-add-qconstant
                    • Atj-add-qconstants-in-term
                    • Atj-gen-shallow-symbol-field
                    • Atj-gen-shallow-rational-id-part
                    • Atj-gen-shallow-number-id-part
                    • Atj-gen-shallow-number-field
                    • Atj-gen-shallow-value
                    • Atj-gen-shallow-cons-fields
                    • Atj-gen-shallow-cons-field
                    • Atj-gen-shallow-string
                    • Atj-gen-shallow-integer-id-part
                    • Atj-gen-shallow-string-field
                    • Atj-gen-shallow-number-field-name
                    • Atj-gen-shallow-char-field
                    • Atj-gen-shallow-char
                    • Atj-gen-shallow-string-field-name
                    • Atj-gen-shallow-cons
                    • Atj-gen-shallow-char-field-name
                    • Atj-gen-shallow-symbol-fields
                    • Atj-gen-shallow-string-fields
                    • Atj-gen-shallow-number-fields
                    • Atj-gen-shallow-number
                    • Atj-gen-shallow-char-fields
                  • Atj-pre-translation
                  • Atj-gen-everything
                  • Atj-name-translation
                  • Atj-gen-test-cunit
                  • Atj-gen-test-class
                  • Atj-gen-main-file
                  • Atj-post-translation
                  • Atj-deep-code-generation
                  • Atj-gen-test-methods
                  • Atj-gen-test-file
                  • Atj-gen-env-file
                  • Atj-gen-output-subdir
                • Atj-java-primitives
                • Atj-java-primitive-arrays
                • Atj-type-macros
                • Atj-java-syntax-operations
                • Atj-fn
                • Atj-library-extensions
                • Atj-java-input-types
                • Atj-test-structures
                • Aij-notions
                • Atj-macro-definition
              • Atj-tutorial
            • Aij
            • Language
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Atj-shallow-quoted-constant-generation

    Atj-add-qconstant

    Add (the value of) a quoted constant to a structured collection.

    Signature
    (atj-add-qconstant value record) → new-record
    Arguments
    record — Guard (atj-qconstants-p record).
    Returns
    new-record — Type (atj-qconstants-p new-record), given the guard.

    We add the value to the appropriate list, unless it is already present. The process is slightly more complicated for cons pairs, as it involves an alist; if the pair is not already in the alist, we add it, associated with the next index to use, and we increment the next index to use in the record.

    Definitions and Theorems

    Function: atj-add-qconstant

    (defun atj-add-qconstant (value record)
     (declare (xargs :guard (atj-qconstants-p record)))
     (let ((__function__ 'atj-add-qconstant))
      (declare (ignorable __function__))
      (b* (((atj-qconstants record) record))
       (cond
        ((integerp value)
         (change-atj-qconstants
              record
              :integers (add-to-set value record.integers)))
        ((rationalp value)
         (change-atj-qconstants
              record
              :rationals (add-to-set value record.rationals)))
        ((acl2-numberp value)
         (change-atj-qconstants
              record
              :numbers (add-to-set value record.numbers)))
        ((characterp value)
         (change-atj-qconstants record
                                :chars (add-to-set value record.chars)))
        ((stringp value)
         (change-atj-qconstants
              record
              :strings (add-to-set-equal value record.strings)))
        ((symbolp value)
         (change-atj-qconstants
              record
              :symbols (add-to-set-eq value record.symbols)))
        ((consp value)
         (b* ((value+index? (assoc-equal value record.pairs)))
           (if (consp value+index?)
               record
             (change-atj-qconstants
                  record
                  :pairs (acons value record.next-index record.pairs)
                  :next-index (1+ record.next-index)))))
        (t
         (prog2$ (raise "Internal error: ~x0 is not a recognized value."
                        value)
                 record))))))

    Theorem: atj-qconstants-p-of-atj-add-qconstant

    (defthm atj-qconstants-p-of-atj-add-qconstant
      (implies (and (atj-qconstants-p record))
               (b* ((new-record (atj-add-qconstant value record)))
                 (atj-qconstants-p new-record)))
      :rule-classes :rewrite)