• 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
              • 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
    • Atc-pretty-printer

    Expr->grade

    Grade of an abstract syntactic expression.

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

    See pprint-expressions for background.

    Definitions and Theorems

    Function: expr->grade

    (defun expr->grade (expr)
      (declare (xargs :guard (exprp expr)))
      (let ((__function__ 'expr->grade))
        (declare (ignorable __function__))
        (expr-case expr
                   :ident (expr-grade-primary)
                   :const (expr-grade-primary)
                   :arrsub (expr-grade-postfix)
                   :call (expr-grade-postfix)
                   :member (expr-grade-postfix)
                   :memberp (expr-grade-postfix)
                   :postinc (expr-grade-postfix)
                   :postdec (expr-grade-postfix)
                   :preinc (expr-grade-unary)
                   :predec (expr-grade-unary)
                   :unary (expr-grade-unary)
                   :cast (expr-grade-cast)
                   :binary (binop-case expr.op
                                       :mul (expr-grade-multiplicative)
                                       :div (expr-grade-multiplicative)
                                       :rem (expr-grade-multiplicative)
                                       :add (expr-grade-additive)
                                       :sub (expr-grade-additive)
                                       :shl (expr-grade-shift)
                                       :shr (expr-grade-shift)
                                       :lt (expr-grade-relational)
                                       :gt (expr-grade-relational)
                                       :le (expr-grade-relational)
                                       :ge (expr-grade-relational)
                                       :eq (expr-grade-equality)
                                       :ne (expr-grade-equality)
                                       :bitand (expr-grade-and)
                                       :bitxor (expr-grade-xor)
                                       :bitior (expr-grade-ior)
                                       :logand (expr-grade-logical-and)
                                       :logor (expr-grade-logical-or)
                                       :asg (expr-grade-assignment)
                                       :asg-mul (expr-grade-assignment)
                                       :asg-div (expr-grade-assignment)
                                       :asg-rem (expr-grade-assignment)
                                       :asg-add (expr-grade-assignment)
                                       :asg-sub (expr-grade-assignment)
                                       :asg-shl (expr-grade-assignment)
                                       :asg-shr (expr-grade-assignment)
                                       :asg-and (expr-grade-assignment)
                                       :asg-xor (expr-grade-assignment)
                                       :asg-ior (expr-grade-assignment))
                   :cond (expr-grade-conditional))))

    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-expr-fix-expr

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

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

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