• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • X86isa
      • Sha-2
      • Yul
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Axe
      • Poseidon
      • Where-do-i-place-my-book
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
              • Compilation
              • Static-semantics
              • Concrete-syntax
                • Pretty-printer
                  • Pprint-expression-algorithm
                  • Expr-grade
                    • Expr-grade-fix
                    • Expr-grade-case
                      • Expr-gradep
                      • Expr-grade-equiv
                      • Expr-grade-kind
                      • Expr-grade-unary
                      • Expr-grade-top
                      • Expr-grade-shift
                      • Expr-grade-primary
                      • Expr-grade-postfix
                      • Expr-grade-ordering
                      • Expr-grade-multiplicative
                      • Expr-grade-exponential
                      • Expr-grade-equality
                      • Expr-grade-disjunctive
                      • Expr-grade-conjunctive
                      • Expr-grade-conditional
                      • Expr-grade-bitwise-xor
                      • Expr-grade-bitwise-ior
                      • Expr-grade-bitwise-and
                      • Expr-grade-additive
                    • Pprint-expression
                    • Expr-grade-<=
                    • Binop-expected-grades
                    • Expr->grade
                    • Pprint-char
                    • Pprint-console
                    • Pprint-var/const-sort
                    • Pprint-indent
                    • Pprint-constdecl
                    • Pprint-vardecl
                    • Pprint-statement
                    • Pprint-type
                    • *binops-opcall-print-names*
                    • Pprint-programdecl
                    • Pprint-line
                    • Pprint-group-literal
                    • Pprint-funparam-list
                    • *unops-opcall-print-names*
                    • Pprint-literal
                    • Pprint-coordinate
                    • Pprint-char-list
                    • Pprint-bitsize-to-utype
                    • Pprint-bitsize-to-itype
                    • Expr-grade-index
                    • Pprint-unop
                    • Pprint-programid
                    • Pprint-importdecl
                    • Pprint-identifier
                    • Pprint-funparam
                    • Pprint-compdecl
                    • Pprint-binop
                    • Pprint-locator
                    • Pprint-compdecl-list
                    • Pprint-address
                    • Pprint-structdecl
                    • Pprint-natural
                    • Pprint-mappingdecl
                    • Pprint-integer
                    • Pprint-fundecl
                    • Pprint-comma-separated
                    • Pprint-boolean
                    • Pprint-annotation-list
                    • Pprint-topdecl-list
                    • Pprint-importdecl-list
                    • Pprint-topdecl
                    • Pprint-annotation
                    • Pprint-file
                    • Pprint-line-blank
                  • Grammar
                  • Lexing-and-parsing
                  • Input-pretty-printer
                  • Output-pretty-printer
                  • Unicode-characters
                  • Concrete-syntax-trees
                  • Symbols
                  • Keywords
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Expr-grade

    Expr-grade-case

    Case macro for the different kinds of expr-grade 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 expr-grade structure, or to split into cases based on its type.

    Short Form

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

    (expr-grade-case x :top)

    is essentially just a safer alternative to writing:

    (equal (expr-grade-kind x) :top)

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

    Long Form

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

    (expr-grade-case x
      :top ...
      :conditional ...
      :disjunctive ...
      :conjunctive ...
      :equality ...
      :ordering ...
      :bitwise-xor ...
      :bitwise-ior ...
      :bitwise-and ...
      :shift ...
      :additive ...
      :multiplicative ...
      :exponential ...
      :unary ...
      :postfix ...
      :primary ...)

    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 :top case, you can use fty::defprod-style foo.bar style accessors for x without having to explicitly add a top b* binder.