• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
        • Defgrammar
        • Tree-utilities
        • Notation
          • Syntax-abstraction
            • Abstract-repeat
            • Abstract-bin/dec/hex-val-rest-dot-p
            • Abstract-*digit-star-*digit
            • Abstract-*-grouped-terminal
            • Abstract-case-insensitive-string
            • Abstract-grouped-terminals
            • Abstract-hexdig
            • Abstract-hex-val-rest
            • Abstract-grouped-terminal
            • Abstract-dec-val-rest
            • Abstract-bin-val-rest
            • Abstract-rulename
            • Abstract-*hexdig
            • Abstract-*digit
            • Abstract-terminals
            • Abstract-terminal
            • Abstract-rule-/-*cwsp-cnl
            • Abstract-digit
              • Abstract-bin/dec/hex-val
              • Abstract-?repeat
              • Abstract-*bit
              • Abstract-rule
              • Abstract-hex-val
              • Abstract-dec-val
              • Abstract-char-val
              • Abstract-bin-val
              • Abstract-alpha/digit/dash
              • Abstract-*-rule-/-*cwsp-cnl
              • Abstract-*-alpha/digit/dash
              • Abstract-quoted-string
              • Abstract-prose-val
              • Abstract-defined-as
              • Abstract-case-sensitive-string
              • Abstract-bit
              • Abstract-*-dot-1*hexdig
              • Abstract-*-dot-1*digit
              • Abstract-*-dot-1*bit
              • Abstract-rulelist
              • Abstract-num-val
              • Abstract-element
              • Abstract-dot/dash-1*hexdig
              • Abstract-dot/dash-1*digit
              • Abstract-elements
              • Abstract-dot/dash-1*bit
              • Abstract-alpha
              • Abstract-repetition
              • Abstract-concatenation
              • Abstract-conc-rest
              • Abstract-alternation
              • Abstract-alt-rest
              • Abstract-group/option
              • Abstract-fail
              • Abstract-conc-rest-comp
              • Abstract-alt-rest-comp
            • Semantics
            • Abstract-syntax
            • Core-rules
            • Concrete-syntax
          • Grammar-parser
          • Meta-circular-validation
          • Parsing-primitives-defresult
          • Parsing-primitives-seq
          • Operations
          • Examples
          • Differences-with-paper
          • Constructor-utilities
          • Grammar-printer
          • Parsing-tools
        • Vwsim
        • Isar
        • Wp-gen
        • Dimacs-reader
        • Pfcs
        • Legacy-defrstobj
        • Proof-checker-array
        • Soft
        • C
        • 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
    • Syntax-abstraction

    Abstract-digit

    A DIGIT parse tree is abstracted to its decimal digit.

    Signature
    (abstract-digit tree) → digit
    Arguments
    tree — Guard (treep tree).
    Returns
    digit — Type (integer-range-p 0 10 digit).

    Definitions and Theorems

    Function: abstract-digit

    (defun abstract-digit (tree)
      (declare (xargs :guard (treep tree)))
      (b* (((fun (fail))
            (prog2$ (abstract-fail) 0))
           ((unless (tree-case tree :nonleaf))
            (fail))
           (treess (tree-nonleaf->branches tree))
           ((unless (consp treess)) (fail))
           (trees (car treess))
           ((unless (consp trees)) (fail))
           (subtree (car trees))
           (nat (abstract-terminal subtree))
           ((unless (and (<= (char-code #\0) nat)
                         (<= nat (char-code #\9))))
            (fail)))
        (- nat (char-code #\0))))

    Theorem: return-type-of-abstract-digit

    (defthm return-type-of-abstract-digit
      (b* ((digit (abstract-digit tree)))
        (integer-range-p 0 10 digit))
      :rule-classes :rewrite)

    Theorem: natp-of-abstract-digit

    (defthm natp-of-abstract-digit
      (b* ((digit (abstract-digit tree)))
        (natp digit))
      :rule-classes :type-prescription)

    Theorem: abstract-digit-linear

    (defthm abstract-digit-linear
      (b* ((digit (abstract-digit tree)))
        (< digit 10))
      :rule-classes :linear)