• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
      • Break-rewrite
      • Proof-builder
      • Accumulated-persistence
      • Cgen
        • Defdata
          • Match
          • Sig
          • Register-data-constructor
            • Register-type
            • Defdata-attach
            • Register-user-combinator
          • Test?
          • ACL2s-defaults
          • Prove/cgen
          • Register-type
          • With-timeout
          • Defdata-attach
          • Testing-enabled
          • Defdata-aliasing-enabled
          • Cgen-single-test-timeout
          • Verbosity-level
          • Search-strategy
          • Num-print-counterexamples
          • Cgen-timeout
          • Cgen-local-timeout
          • Num-witnesses
          • Num-trials
          • Num-print-witnesses
          • Test-then-skip-proofs
          • Sampling-method
          • Recursively-fix
          • Num-counterexamples
          • Backtrack-limit
          • Print-cgen-summary
          • Cgen::flush
          • Backtrack-bad-generalizations
          • Use-fixers
          • Thm-no-test
          • Defthmd-no-test
          • Defthm-no-test
        • Forward-chaining-reports
        • Proof-tree
        • Print-gv
        • Dmr
        • With-brr-data
        • Splitter
        • Guard-debug
        • Set-debugger-enable
        • Redo-flat
        • Time-tracker
        • Set-check-invariant-risk
        • Removable-runes
        • Efficiency
        • Explain-near-miss
        • Tail-biting
        • Failed-forcing
        • Sneaky
        • Invariant-risk
        • Failure
        • Measure-debug
        • Dead-events
        • Compare-objects
        • Prettygoals
        • Remove-hyps
        • Type-prescription-debugging
        • Pstack
        • Trace
        • Set-register-invariant-risk
        • Walkabout
        • Disassemble$
        • Nil-goal
        • Cw-gstack
        • Set-guard-msg
        • Find-lemmas
        • Watch
        • Quick-and-dirty-subsumption-replacement-step
        • Profile-all
        • Profile-ACL2
        • Set-print-gv-defaults
        • Minimal-runes
        • Spacewalk
        • Try-gl-concls
        • Near-misses
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Defdata

    Register-data-constructor

    Register a data constructor (to extend the defdata language)

    Introduction

    You must be familiar with compound data types specified by defdata using cons. Although cons has a unique status in ACL2, it is not natively available in the defdata language unlike built-in combinators such as oneof and range. In fact, advanced users can introduce custom notions of product data by using the register-data-constructor macro, whose usage we show below.

    Example

    Consider the symbol-alist type defined as (oneof nil (cons (cons symbol all) symbol-alist)). We could have registered acons as a data constructor, and alternatively defined symbol-alist using acons instead of cons.

    (defun aconsp (x)
      (and (consp x) (consp (car x))))
    
    (defun acons-caar (x)  (caar x))
    (defun acons-cdar (x)  (cdar x))
    (defun acons-cdr  (x)  (cdr x))
    
    (register-data-constructor (aconsp acons)
                               ((allp acons-caar) (allp acons-cdar) (allp acons-cdr)))
    
    (defdata symbol-alist (oneof nil (acons symbol all symbol-alist)))

    In fact, this is how we setup the base environment in "defdata/base.lisp": we use register-data-constructor to preregister all the primitive data constructors in ACL2. In particular, the following (primitive) constructors are available to build product types: cons, intern$, / and complex.

    General Form:

    (register-data-constructor (recognizer constructor)
                               ((destructor-pred1 destructor1) ...)
                               [:proper bool]
                               [:hints hints]
                               [:rule-classes rule-classes])