• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
      • B*
      • Defunc
      • Fty
        • Deftagsum
        • Defprod
        • Defflexsum
        • Defbitstruct
        • Deflist
        • Defalist
        • Defbyte
        • Deffixequiv
        • Defresult
        • Deffixtype
        • Defoption
          • Fty-discipline
          • Fold
          • Fty-extensions
          • Defsubtype
          • Defset
          • Deftypes
          • Specific-types
          • Defflatsum
          • Deflist-of-len
          • Defbytelist
          • Defomap
          • Fty::basetypes
          • Defvisitors
          • Deffixtype-alias
          • Deffixequiv-sk
          • Defunit
          • Multicase
          • Deffixequiv-mutual
          • Fty::baselists
          • Def-enumcase
          • Defmap
        • Apt
        • Std/util
        • Defdata
        • Defrstobj
        • Seq
        • Match-tree
        • Defrstobj
        • With-supporters
        • Def-partial-measure
        • Template-subst
        • Soft
        • Defthm-domain
        • Event-macros
        • Def-universal-equiv
        • Def-saved-obligs
        • With-supporters-after
        • Definec
        • Sig
        • Outer-local
        • Data-structures
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Fty
    • Deftypes

    Defoption

    Define an option type.

    defoption generates a recognizer predicate and fixing function for a new type whose elements either belong to the argument type or are nil. This is analogous to the "option" or "maybe" types of various other languages, except that defoption types are untagged. In order to distinguish the nil case from the argument type, the recognizer for the argument type must not admit nil.

    defoption is compatible with deftypes and can be mutually-recursive with other deftypes-compatible type generators.

    The syntax of defoption is:

    (defoption foo-option
      foo                  ;; type argument
      :parents (...)       ;; xdoc
      :short "..."         ;; xdoc
      :long "..."          ;; xdoc
      :measure (+ 1 (* 2 (acl2-count x)))
                           ;; default: (acl2-count x)
      :xvar x              ;; default: x, or find x symbol in measure
      :prepwork            ;; admit these events before starting
      :pred foo?-p         ;; default: foo-option-p
      :fix foo?-fix        ;; default: foo-option-fix
      :equiv foo?-=        ;; default: foo-option-equiv
      :case  foo?-case     ;; default: foo-option-case
      :count foo?-cnt      ;; default: foo-option-count
                           ;; (may be nil; skipped unless mutually recursive)
      :inline (:kind :fix) ;; default: (:kind :fix :acc)
      )

    Note that the type argument must precede any keyword arguments.