• 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
                  • 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
    • Pretty-printer

    Expr->grade

    Grade of an abstract syntactic expression.

    Signature
    (expr->grade expr) → grade
    Arguments
    expr — Guard (expressionp expr).
    Returns
    grade — Type (expr-gradep grade).

    See pprint-expression-algorithm for background.

    Definitions and Theorems

    Function: expr->grade

    (defun expr->grade (expr)
      (declare (xargs :guard (expressionp expr)))
      (let ((__function__ 'expr->grade))
        (declare (ignorable __function__))
        (expression-case
             expr
             :literal (expr-grade-primary)
             :var/const (expr-grade-primary)
             :assoc-const (expr-grade-primary)
             :unary (expr-grade-unary)
             :binary (binop-case expr.op
                                 :pow (expr-grade-exponential)
                                 :mul (expr-grade-multiplicative)
                                 :div (expr-grade-multiplicative)
                                 :rem (expr-grade-multiplicative)
                                 :add (expr-grade-additive)
                                 :sub (expr-grade-additive)
                                 :shr (expr-grade-shift)
                                 :shl (expr-grade-shift)
                                 :bitand (expr-grade-bitwise-and)
                                 :bitior (expr-grade-bitwise-ior)
                                 :bitxor (expr-grade-bitwise-xor)
                                 :lt (expr-grade-ordering)
                                 :gt (expr-grade-ordering)
                                 :le (expr-grade-ordering)
                                 :ge (expr-grade-ordering)
                                 :eq (expr-grade-equality)
                                 :ne (expr-grade-equality)
                                 :and (expr-grade-conjunctive)
                                 :or (expr-grade-disjunctive)
                                 :nand (expr-grade-postfix)
                                 :nor (expr-grade-postfix)
                                 :pow-wrapped (expr-grade-postfix)
                                 :mul-wrapped (expr-grade-postfix)
                                 :div-wrapped (expr-grade-postfix)
                                 :rem-wrapped (expr-grade-postfix)
                                 :add-wrapped (expr-grade-postfix)
                                 :sub-wrapped (expr-grade-postfix)
                                 :shr-wrapped (expr-grade-postfix)
                                 :shl-wrapped (expr-grade-postfix))
             :unit (expr-grade-primary)
             :tuple (expr-grade-primary)
             :tuple-component (expr-grade-postfix)
             :struct (expr-grade-primary)
             :struct-component (expr-grade-postfix)
             :cond (expr-grade-conditional)
             :internal-call (expr-grade-primary)
             :external-call (expr-grade-primary)
             :static-call (expr-grade-primary))))

    Theorem: expr-gradep-of-expr->grade

    (defthm expr-gradep-of-expr->grade
      (b* ((grade (expr->grade expr)))
        (expr-gradep grade))
      :rule-classes :rewrite)

    Theorem: expr->grade-of-expression-fix-expr

    (defthm expr->grade-of-expression-fix-expr
      (equal (expr->grade (expression-fix expr))
             (expr->grade expr)))

    Theorem: expr->grade-expression-equiv-congruence-on-expr

    (defthm expr->grade-expression-equiv-congruence-on-expr
      (implies (expression-equiv expr expr-equiv)
               (equal (expr->grade expr)
                      (expr->grade expr-equiv)))
      :rule-classes :congruence)