• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
        • Equivalences
          • Charlisteqv
          • Icharlisteqv
          • Istreqv
          • Ichareqv
            • Streqv
            • Chareqv
            • Char-fix
            • Str-fix
          • Url-encoding
          • Lines
          • Explode-implode-equalities
          • Ordering
          • Numbers
          • Pad-trim
          • Coercion
          • Std/strings/digit-to-char
          • Substitution
          • Symbols
        • Std/osets
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Equivalences
    • Cases

    Ichareqv

    Case-insensitive character equivalence test.

    Signature
    (ichareqv x y) → bool

    (ichareqv x y) determines if x and y are equivalent when interpreted as characters without regard to case. For instance, upper-case C is equivalent to lower-case c under this relation.

    ACL2 has a built-in version of this function, char-equal, but it is irritating to use because it has standard-char-p guards. In contrast, ichareqv works on arbitrary characters, with some loss of efficiency.

    Definitions and Theorems

    Function: ichareqv$inline

    (defun ichareqv$inline (x y)
      (declare (type character x)
               (type character y))
      (let ((acl2::__function__ 'ichareqv))
        (declare (ignorable acl2::__function__))
        (eql (downcase-char x)
             (downcase-char y))))

    Theorem: ichareqv-is-an-equivalence

    (defthm ichareqv-is-an-equivalence
      (and (booleanp (ichareqv x y))
           (ichareqv x x)
           (implies (ichareqv x y) (ichareqv y x))
           (implies (and (ichareqv x y) (ichareqv y z))
                    (ichareqv x z)))
      :rule-classes (:equivalence))

    Theorem: chareqv-refines-ichareqv

    (defthm chareqv-refines-ichareqv
      (implies (chareqv x y) (ichareqv x y))
      :rule-classes (:refinement))

    Theorem: equal-of-upcase-char-and-upcase-char

    (defthm equal-of-upcase-char-and-upcase-char
      (equal (equal (upcase-char x) (upcase-char y))
             (ichareqv x y)))

    Theorem: ichareqv-implies-equal-downcase-char-1

    (defthm ichareqv-implies-equal-downcase-char-1
      (implies (ichareqv x x-equiv)
               (equal (downcase-char x)
                      (downcase-char x-equiv)))
      :rule-classes (:congruence))

    Theorem: ichareqv-implies-equal-upcase-char-1

    (defthm ichareqv-implies-equal-upcase-char-1
      (implies (ichareqv x x-equiv)
               (equal (upcase-char x)
                      (upcase-char x-equiv)))
      :rule-classes (:congruence))

    Theorem: ichareqv-implies-equal-upcase-char-str-1

    (defthm ichareqv-implies-equal-upcase-char-str-1
      (implies (ichareqv x x-equiv)
               (equal (upcase-char-str x)
                      (upcase-char-str x-equiv)))
      :rule-classes (:congruence))

    Theorem: ichareqv-implies-equal-downcase-char-str-1

    (defthm ichareqv-implies-equal-downcase-char-str-1
      (implies (ichareqv x x-equiv)
               (equal (downcase-char-str x)
                      (downcase-char-str x-equiv)))
      :rule-classes (:congruence))