• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
        • Syntax-for-tools
        • Atc
          • Atc-implementation
            • Atc-abstract-syntax
            • Atc-pretty-printer
              • Pprint-expressions
              • Pprint-expr
              • Expr-grade
                • Expr-grade-fix
                • Expr-grade-case
                  • Expr-gradep
                  • Expr-grade-equiv
                  • Expr-grade-kind
                  • Expr-grade-xor
                  • Expr-grade-unary
                  • Expr-grade-top
                  • Expr-grade-shift
                  • Expr-grade-relational
                  • Expr-grade-primary
                  • Expr-grade-postfix
                  • Expr-grade-multiplicative
                  • Expr-grade-logical-or
                  • Expr-grade-logical-and
                  • Expr-grade-ior
                  • Expr-grade-equality
                  • Expr-grade-conditional
                  • Expr-grade-cast
                  • Expr-grade-assignment
                  • Expr-grade-and
                  • Expr-grade-additive
                • Pprint-obj-declor
                • Expr-grade-<=
                • Binop-expected-grades
                • Pprint-obj-declon
                • Expr->grade
                • Pprint-tyspecseq
                • Pprint-tag-declon
                • Pprint-struct-declon-list
                • Pprint-fun-declor
                • Pprint-file
                • Pprint-stmt
                • Pprint-struct-declon
                • Pprint-obj-adeclor
                • Pprint-initer
                • Pprint-fun-declon
                • Pprint-indent
                • Pprint-hex-const
                • Pprint-fileset
                • Pprint-dec-const
                • Pprinted-lines-to-file
                • Pprint-tyname
                • Pprint-param-declon-list
                • Pprint-oct-const
                • Pprint-iconst-length
                • Pprint-iconst
                • Pprint-const
                • Expr-grade-index
                • Pprint-param-declon
                • Pprint-label
                • Pprint-ident-list
                • Pprint-binop
                • Pprint-fundef
                • Pprint-file-to-filesystem
                • Pprint-ext-declon-list
                • Pprint-unop
                • Pprint-line
                • Pprint-ident
                • Pprint-ext-declon
                • Pprint-comma-sep
                • Pprint-transunit
                • Pprint-one-line
                • Pprinted-lines-to-channel
                • Pprint-one-line-blank
                • Pprint-line-blank
              • Atc-event-and-code-generation
              • Fty-pseudo-term-utilities
              • Atc-term-recognizers
              • Atc-input-processing
              • Atc-shallow-embedding
              • Atc-process-inputs-and-gen-everything
              • Atc-table
              • Atc-fn
              • Atc-pretty-printing-options
              • Atc-types
              • Atc-macro-definition
            • Atc-tutorial
          • Language
          • Representation
          • Transformation-tools
          • Insertion-sort
          • Pack
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • 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 ...
      :assignment ...
      :conditional ...
      :logical-or ...
      :logical-and ...
      :ior ...
      :xor ...
      :and ...
      :equality ...
      :relational ...
      :shift ...
      :additive ...
      :multiplicative ...
      :cast ...
      :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.