• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
          • Defbyte
          • Defresult
          • Fold
            • Deffold-reduce
              • Deffold-reduce-implementation
                • Deffold-reduce-event-generation
                • Deffoldred-process-inputs-and-gen-everything
                • Deffoldred-fn
                • Deffold-reduce-input-processing
                  • Deffoldred-process-inputs
                  • Deffoldred-process-override
                    • Deffoldred-process-types
                    • *deffoldred-allowed-options*
                  • Deffoldred-macro-definition
              • Deffold-map
              • Defmake-self
            • Specific-types
            • Defsubtype
            • Defset
            • Defflatsum
            • Deflist-of-len
            • Pos-list
            • Defomap
            • Defbytelist
            • Defbyte-standard-instances
            • Deffixtype-alias
            • Defbytelist-standard-instances
            • Defunit
            • Byte-list
            • Database
            • Byte
            • String-option
            • Pos-option
            • Nibble
            • Nat-option
            • Ubyte32-option
            • Byte-list20
            • Byte-list32
            • Byte-list64
            • Pseudo-event-form
            • Natoption/natoptionlist
            • Nati
            • Character-list
            • Nat/natlist
            • Maybe-string
            • Nibble-list
            • Natoption/natoptionlist-result
            • Nat/natlist-result
            • Nat-option-list-result
            • Set
            • String-result
            • String-list-result
            • Nat-result
            • Nat-option-result
            • Nat-list-result
            • Maybe-string-result
            • Integer-result
            • Character-result
            • Character-list-result
            • Boolean-result
            • Map
            • Dependencies
            • Bag
            • Pos-set
            • Hex-digit-char-list
            • Dec-digit-char-list
            • Pseudo-event-form-list
            • Nat-option-list
            • Character-any-map
            • Any-nat-map
            • Symbol-set
            • String-set
            • Nat-set
            • Character-set
            • Oct-digit-char-list
            • Bin-digit-char-list
            • Bit-list
          • Isar
          • Kestrel-utilities
          • Set
          • C
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Deffold-reduce-input-processing

    Deffoldred-process-override

    Process the :override input.

    Signature
    (deffoldred-process-override override fty-table) 
      → 
    (mv erp overrides)
    Arguments
    fty-table — Guard (alistp fty-table).
    Returns
    overrides — Type (alistp overrides).

    The :override input must be a list. We go through each eleemnt, which must be a 2-tuple or a 3-tuple. In that tuple, the first element must be always a type name, which we must find in the FTY table. Both sum and product types are stored in the table as sum types, but the data structure indicates the type macro, i.e. whether it is a defprod or deftagsum; we use that to distinguish them.

    Definitions and Theorems

    Function: deffoldred-process-override-loop

    (defun deffoldred-process-override-loop (override fty-table)
     (declare (xargs :guard (and (true-listp override)
                                 (alistp fty-table))))
     (let ((__function__ 'deffoldred-process-override-loop))
      (declare (ignorable __function__))
      (b*
       (((reterr) nil)
        ((when (endp override)) (retok nil))
        (ovrd (car override))
        ((unless (or (std::tuplep 2 ovrd)
                     (std::tuplep 3 ovrd)))
         (reterr
          (msg
           "Every element of the :OVERRIDE list ~
                             must be a list of 2 or 3 elements, ~
                             but the element ~x0 is not."
           ovrd)))
        (type (car ovrd))
        (term (car (last ovrd)))
        ((unless (symbolp type))
         (reterr
          (msg
           "The first element of ~
                             every element of the :OVERRIDE list ~
                             must be a symbol, ~
                             but ~x0 is not."
           type)))
        (info (flextype-with-name type fty-table))
        ((unless info)
         (reterr
          (msg
           "The first element of ~
                             every element of the :OVERRIDE list ~
                             must be the name of a type, ~
                             but ~x0 is not."
           type)))
        ((unless (flexsum-p info))
         (reterr
          (msg
           "The first element of ~
                             every element of the :OVERRIDE list ~
                             must be the name of a product or sum type, ~
                             but ~x0 is not."
           type)))
        (typemacro (flexsum->typemacro info))
        ((unless (member-eq typemacro (list 'defprod 'deftagsum)))
         (reterr
          (msg
           "The first element of ~
                             every element of the :OVERRIDE list ~
                             must be the name of a product or sum type, ~
                             but ~x0 is not."
           type)))
        ((erp key val)
         (if (= (len ovrd) 2)
             (mv nil type term)
          (b*
           (((reterr) nil nil)
            (kind (cadr ovrd))
            ((unless (keywordp kind))
             (reterr
              (msg
               "The second element of ~
                                     every element of the :OVERRIDE list ~
                                     that is a 3-tuple ~
                                     must be a keyword, ~
                                     but ~x0 is not."
               kind)))
            (prods (flexsum->prods info))
            ((unless (flexprod-listp prods))
             (raise "Internal error: malformed summands ~x0."
                    prods)
             (reterr t))
            ((unless (member-eq kind (flexprod-list->kind-list prods)))
             (reterr
              (msg
               "The kind ~x0 that accompanies ~
                                     the type ~x1 in the :OVERRIDE list ~
                                     is not one of the kinds of that sum type."
               kind type))))
           (retok (cons type kind) term))))
        ((erp alist)
         (deffoldred-process-override-loop (cdr override)
                                           fty-table)))
       (retok (acons key val alist)))))

    Theorem: alistp-of-deffoldred-process-override-loop.overrides

    (defthm alistp-of-deffoldred-process-override-loop.overrides
      (b* (((mv ?erp ?overrides)
            (deffoldred-process-override-loop override fty-table)))
        (alistp overrides))
      :rule-classes :rewrite)

    Function: deffoldred-process-override

    (defun deffoldred-process-override (override fty-table)
     (declare (xargs :guard (alistp fty-table)))
     (let ((__function__ 'deffoldred-process-override))
      (declare (ignorable __function__))
      (b*
       (((reterr) nil)
        ((unless (true-listp override))
         (reterr
          (msg
           "The :OVERRIDE input must be a list, ~
                          but it is ~x0 instead."
           override))))
       (deffoldred-process-override-loop override fty-table))))

    Theorem: alistp-of-deffoldred-process-override.overrides

    (defthm alistp-of-deffoldred-process-override.overrides
      (b* (((mv ?erp ?overrides)
            (deffoldred-process-override override fty-table)))
        (alistp overrides))
      :rule-classes :rewrite)