• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
          • Aij
          • Language
            • Syntax
              • Grammar
              • Unicode-escapes
                • Uniescape-parse-constraints-p
                • Even-backslashes-tree-constraints-p
                • Len-of-string-of-prefix-of-unicode-input-character-trees
                • Uniescape-parse
                • Nonzero-uletters-after-p
                • Abs-unicode-escape
                • Even-backslashes-before-p
                  • Uniescape-tree-constraints-p
                  • Uniescape-process
                  • Uniescape-candidate-valid-p
                  • Uniescape-candidate-p
                  • Abs-raw-input-character
                  • Abs-hex-digit
                  • Abs-unicode-input-character
                  • Some-uniescape-candidate-invalid-p
                  • Uniescapep
                  • Abs-unicode-input-character-list
                  • Uniescape-parse-p
                  • Eligible-backslash-p
                  • Unicode-input-character-tree-is-escape-p
                • Unicode-input-char
                • Escape-sequence
                • Identifiers
                • Primitive-types
                • Reference-types
                • Keywords
                • Unicode-characters
                • Integer-literals
                • String-literals
                • Octal-digits
                • Hexadecimal-digits
                • Decimal-digits
                • Binary-digits
                • Character-literals
                • Null-literal
                • Floating-point-literals
                • Boolean-literals
                • Package-names
                • Literals
              • Semantics
          • Riscv
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Unicode-escapes

    Even-backslashes-before-p

    Check if, in a list of Unicode characters, the character at position pos is preceded by an even number of backslashes.

    This is used to define the notion of eligible backslash.

    Note that (take n (nthcdr (- pos n) unicodes)) consists of the characters from position (- pos n) to (- pos 1), both extremes inclusive (positions in lists are zero-based).

    Formally, it is not sufficient just to say that there are n backslashes just before pos with n even: we must also say that there is no backslash just before (- pos n), either because the list starts there (i.e. pos is n) or because the character at (- (- pos n) 1) is not a backslash; this is expressed by the last conjunct inside the quantification.

    This definition works fine if n is 0.

    Definitions and Theorems

    Theorem: even-backslashes-before-p-suff

    (defthm even-backslashes-before-p-suff
      (implies (and (natp n)
                    (evenp n)
                    (>= (- pos n) 0)
                    (equal (take n (nthcdr (- pos n) unicodes))
                           (repeat n (char-code #\\)))
                    (or (equal (- pos n) 0)
                        (not (equal (nth (1- (- pos n)) unicodes)
                                    (char-code #\\)))))
               (even-backslashes-before-p pos unicodes)))

    Theorem: booleanp-of-even-backslashes-before-p

    (defthm booleanp-of-even-backslashes-before-p
      (b* ((yes/no (even-backslashes-before-p pos unicodes)))
        (booleanp yes/no))
      :rule-classes :rewrite)