• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • 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
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
                • Jbinop
                  • Jbinopp
                  • Jbinop-fix
                  • Jbinop-case
                    • Jbinop-kind
                    • Jbinop-equiv
                    • Jbinop-add
                    • Jbinop-sub
                    • Jbinop-xor
                    • Jbinop-ushr
                    • Jbinop-sshr
                    • Jbinop-shl
                    • Jbinop-rem
                    • Jbinop-ne
                    • Jbinop-mul
                    • Jbinop-lt
                    • Jbinop-le
                    • Jbinop-ior
                    • Jbinop-gt
                    • Jbinop-ge
                    • Jbinop-eq
                    • Jbinop-div
                    • Jbinop-condor
                    • Jbinop-condand
                    • Jbinop-asg-xor
                    • Jbinop-asg-ushr
                    • Jbinop-asg-sub
                    • Jbinop-asg-sshr
                    • Jbinop-asg-shl
                    • Jbinop-asg-rem
                    • Jbinop-asg-mul
                    • Jbinop-asg-ior
                    • Jbinop-asg-div
                    • Jbinop-asg-and
                    • Jbinop-asg-add
                    • Jbinop-asg
                    • Jbinop-and
                  • Jmethod
                  • Jtype
                  • Jfield
                  • Jexprs
                  • Jliteral
                  • Junop
                  • Jlocvar
                  • Jcunit
                  • Jaccess
                  • Maybe-jexpr
                  • Jparam
                  • Jimport
                  • Jcinitializer
                  • Jresult
                  • Jstatems+jblocks
                  • Jexpr-get-field
                  • Jliteral-long-dec-nouscores
                  • Nat-to-dec-chars-theorems
                  • Jmethods-to-jcbody-elements
                  • Jclasses-to-jcbody-elements
                  • Jblock-locvar-final
                  • Jblock-locvar
                  • Jliteral-int-dec-nouscores
                  • Jfields-to-jcbody-elements
                  • Jblock-for
                  • Jblock-smethod
                  • Jblock-imethod
                  • Jblock-ifelse
                  • Jblock-asg-name
                  • Jparam-list->types
                  • Jparam-list->names
                  • Jexpr-lit-long-dec-nouscores
                  • Jexpr-lit-int-dec-nouscores
                  • Jexpr-literal-string
                  • Jexpr-literal-floating
                  • Jexpr-literal-character
                  • Jblock-while
                  • Jblock-method
                  • Jblock-if
                  • Jblock-expr
                  • Jblock-do
                  • Jblock-asg
                  • Jexpr-name-list
                  • Jblock-throw
                  • Jblock-return
                  • Jparam-list
                  • Jimport-list
                  • Jexpr-literal-true
                  • Jexpr-literal-null
                  • Jexpr-literal-false
                  • Jexpr-literal-1
                  • Jexpr-literal-0
                  • Jclass-list
                  • Jblock-continue
                  • Jtype-short
                  • Jtype-long
                  • Jtype-list
                  • Jtype-int
                  • Jtype-float
                  • Jtype-double
                  • Jtype-char
                  • Jtype-byte
                  • Jtype-boolean
                  • Jmethod-list
                  • Jliteral-list
                  • Jfield-list
                  • Jblock-list
                  • Jblock-break
                  • Jclasses+jcmembers
                • Atj-input-processing
                • Atj-java-pretty-printer
                • Atj-code-generation
                • 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
    • Jbinop

    Jbinop-case

    Case macro for the different kinds of jbinop structures.

    This is an ACL2::fty sum-type case macro, typically introduced by fty::defflexsum or fty::deftagsum. It allows you to safely check the type of a jbinop structure, or to split into cases based on its type.

    Short Form

    In its short form, jbinop-case allows you to safely check the type of a jbinop structure. For example:

    (jbinop-case x :mul)

    is essentially just a safer alternative to writing:

    (equal (jbinop-kind x) :mul)

    Why is using jbinop-case safer? When we directly inspect the kind with equal, there is no static checking being done to ensure that, e.g., :mul is a valid kind of jbinop structure. That means there is nothing to save you if, later, you change the kind keyword for this type from :mul to something else. It also means you get no help if you just make a typo when writing the :mul symbol. Over the course of developing VL, we found that such issues were very frequent sources of errors!

    Long Form

    In its longer form, jbinop-case allows you to split into cases based on the kind of structure you are looking at. A typical example would be:

    (jbinop-case x
      :mul ...
      :div ...
      :rem ...
      :add ...
      :sub ...
      :shl ...
      :sshr ...
      :ushr ...
      :lt ...
      :gt ...
      :le ...
      :ge ...
      :eq ...
      :ne ...
      :and ...
      :xor ...
      :ior ...
      :condand ...
      :condor ...
      :asg ...
      :asg-mul ...
      :asg-div ...
      :asg-rem ...
      :asg-add ...
      :asg-sub ...
      :asg-shl ...
      :asg-sshr ...
      :asg-ushr ...
      :asg-and ...
      :asg-xor ...
      :asg-ior ...)

    It is also possible to consolidate ``uninteresting'' cases using :otherwise.

    For convenience, the case macro automatically binds the fields of x for you, as appropriate for each case. That is, in the :mul case, you can use fty::defprod-style foo.bar style accessors for x without having to explicitly add a mul b* binder.