• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
          • Atc
            • Atc-implementation
              • Atc-abstract-syntax
              • Atc-pretty-printer
              • Atc-event-and-code-generation
              • Fty-pseudo-term-utilities
              • Atc-term-recognizers
              • Atc-input-processing
              • Atc-shallow-embedding
                • Defstruct
                  • Defstruct-implementation
                    • Defstruct-info
                    • Defstruct-gen-recognizer
                    • Defstruct-gen-integer-member-ops
                    • Defstruct-gen-constructor
                    • Defstruct-gen-array-member-ops
                    • Defstruct-gen-recognizer-conjuncts
                    • Defstruct-member-info
                    • Defstruct-member-info-list->memtype-list
                    • Defstruct-process-members
                    • Defstruct-gen-fixer
                    • Defstruct-gen-member-ops
                    • Defstruct-process-inputs
                    • Defstruct-gen-fixing-term
                      • Defstruct-info-option
                      • Defstruct-gen-everything
                      • Defstruct-gen-all-member-ops
                      • Defstruct-gen-recognizer-all-conjuncts
                      • Defstruct-info->writer-element-list
                      • Defstruct-info->reader-element-list
                      • Defstruct-gen-fixtype
                      • Defstruct-info->writer-list
                      • Defstruct-info->reader-list
                      • Defstruct-fn
                      • Defstruct-table-record-event
                      • Defstruct-table-lookup
                      • Irr-defstruct-info
                      • Defstruct-info->writer-element-list-aux
                      • Defstruct-info->reader-element-list-aux
                      • Defstruct-info->writer-list-aux
                      • Defstruct-info->reader-list-aux
                      • Defstruct-member-info-list
                      • Defstruct-table-definition
                      • *defstruct-table*
                      • Defstruct-macro-implementtion
                  • Defobject
                  • Atc-let-designations
                  • Pointer-types
                  • Atc-conditional-expressions
                • Atc-process-inputs-and-gen-everything
                • Atc-table
                • Atc-fn
                • Atc-pretty-printing-options
                • Atc-types
                • Atc-macro-definition
              • Atc-tutorial
            • Language
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • 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
    • Defstruct-implementation

    Defstruct-gen-fixing-term

    Generate the fixing term for a member of a given type.

    Signature
    (defstruct-gen-fixing-term type) → term
    Arguments
    type — Guard (typep type).
    Returns
    term — An untranslated term.

    This is used in defstruct-gen-fixer. We only the types allowed for structure memberd by defstruct.

    Definitions and Theorems

    Function: defstruct-gen-fixing-term

    (defun defstruct-gen-fixing-term (type)
     (declare (xargs :guard (typep type)))
     (let ((__function__ 'defstruct-gen-fixing-term))
      (declare (ignorable __function__))
      (type-case
       type :void
       (raise "Internal error: type ~x0." type)
       :char
       (raise "Internal error: type ~x0." type)
       :schar '(schar-from-integer 0)
       :uchar '(uchar-from-integer 0)
       :sshort '(sshort-from-integer 0)
       :ushort '(ushort-from-integer 0)
       :sint '(sint-from-integer 0)
       :uint '(uint-from-integer 0)
       :slong '(slong-from-integer 0)
       :ulong '(ulong-from-integer 0)
       :sllong '(sllong-from-integer 0)
       :ullong '(ullong-from-integer 0)
       :struct
       (raise "Internal error: type ~x0." type)
       :pointer
       (raise "Internal error: type ~x0." type)
       :array
       (b* ((size (or type.size 1)))
        (type-case
         type.of
         :void (raise "Internal error: type ~x0." type)
         :char (raise "Internal error: type ~x0." type)
         :schar
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
                '(type-schar)
                (cons ':elements
                      (cons (cons 'repeat
                                  (cons size '((schar-from-integer 0))))
                            'nil)))))
         :uchar
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
                '(type-uchar)
                (cons ':elements
                      (cons (cons 'repeat
                                  (cons size '((uchar-from-integer 0))))
                            'nil)))))
         :sshort
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
               '(type-sshort)
               (cons ':elements
                     (cons (cons 'repeat
                                 (cons size '((sshort-from-integer 0))))
                           'nil)))))
         :ushort
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
               '(type-ushort)
               (cons ':elements
                     (cons (cons 'repeat
                                 (cons size '((ushort-from-integer 0))))
                           'nil)))))
         :sint
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons '(type-sint)
                 (cons ':elements
                       (cons (cons 'repeat
                                   (cons size '((sint-from-integer 0))))
                             'nil)))))
         :uint
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons '(type-uint)
                 (cons ':elements
                       (cons (cons 'repeat
                                   (cons size '((uint-from-integer 0))))
                             'nil)))))
         :slong
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
                '(type-slong)
                (cons ':elements
                      (cons (cons 'repeat
                                  (cons size '((slong-from-integer 0))))
                            'nil)))))
         :ulong
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
                '(type-ulong)
                (cons ':elements
                      (cons (cons 'repeat
                                  (cons size '((ulong-from-integer 0))))
                            'nil)))))
         :sllong
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
               '(type-sllong)
               (cons ':elements
                     (cons (cons 'repeat
                                 (cons size '((sllong-from-integer 0))))
                           'nil)))))
         :ullong
         (cons
          'make-value-array
          (cons
           ':elemtype
           (cons
               '(type-ullong)
               (cons ':elements
                     (cons (cons 'repeat
                                 (cons size '((ullong-from-integer 0))))
                           'nil)))))
         :struct (raise "Internal error: type ~x0." type)
         :pointer (raise "Internal error: type ~x0." type)
         :array (raise "Internal error: type ~x0." type))))))

    Theorem: defstruct-gen-fixing-term-of-type-fix-type

    (defthm defstruct-gen-fixing-term-of-type-fix-type
      (equal (defstruct-gen-fixing-term (type-fix type))
             (defstruct-gen-fixing-term type)))

    Theorem: defstruct-gen-fixing-term-type-equiv-congruence-on-type

    (defthm defstruct-gen-fixing-term-type-equiv-congruence-on-type
      (implies (type-equiv type type-equiv)
               (equal (defstruct-gen-fixing-term type)
                      (defstruct-gen-fixing-term type-equiv)))
      :rule-classes :congruence)