• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • 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
        • Url-encoding
        • Lines
        • Ordering
          • Charlistnat<
          • Istr<
          • Ichar<
          • Icharlist<
            • Strnat<
            • Istrsort
          • Numbers
          • Pad-trim
          • Coercion
          • Std/strings-extensions
          • Std/strings/digit-to-char
          • Substitution
          • Symbols
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Ordering

    Icharlist<

    Case-insensitive character-list less-than test.

    (icharlist< x y) determines whether the character list x preceeds y in alphabetical order without regards to case. The characters are compared with ichar< and shorter strings are considered smaller than longer strings.

    Definitions and Theorems

    Function: icharlist<

    (defun
     icharlist< (x y)
     (declare (xargs :guard (and (character-listp x)
                                 (character-listp y))))
     (mbe
      :logic (cond ((atom y) nil)
                   ((atom x) t)
                   ((ichar< (car x) (car y)) t)
                   ((ichar< (car y) (car x)) nil)
                   (t (icharlist< (cdr x) (cdr y))))
      :exec
      (cond
       ((atom y) nil)
       ((atom x) t)
       (t
        (let* ((xc (the (unsigned-byte 8)
                        (char-code (the character (car x)))))
               (yc (the (unsigned-byte 8)
                        (char-code (the character (car y)))))
               (xc-fix (if (and (<= (big-a) (the (unsigned-byte 8) xc))
                                (<= (the (unsigned-byte 8) xc) (big-z)))
                           (the (unsigned-byte 8)
                                (+ (the (unsigned-byte 8) xc) 32))
                           (the (unsigned-byte 8) xc)))
               (yc-fix (if (and (<= (big-a) (the (unsigned-byte 8) yc))
                                (<= (the (unsigned-byte 8) yc) (big-z)))
                           (the (unsigned-byte 8)
                                (+ (the (unsigned-byte 8) yc) 32))
                           (the (unsigned-byte 8) yc))))
              (cond ((< (the (unsigned-byte 8) xc-fix)
                        (the (unsigned-byte 8) yc-fix))
                     t)
                    ((< (the (unsigned-byte 8) yc-fix)
                        (the (unsigned-byte 8) xc-fix))
                     nil)
                    (t (icharlist< (cdr x) (cdr y)))))))))

    Theorem: icharlist<-irreflexive

    (defthm icharlist<-irreflexive
            (equal (icharlist< x x) nil))

    Theorem: icharlist<-antisymmetric

    (defthm icharlist<-antisymmetric
            (implies (icharlist< x y)
                     (not (icharlist< y x))))

    Theorem: icharlist<-transitive

    (defthm icharlist<-transitive
            (implies (and (icharlist< x y) (icharlist< y z))
                     (icharlist< x z)))

    Theorem: icharlist<-trichotomy-weak

    (defthm icharlist<-trichotomy-weak
            (implies (and (not (icharlist< x y))
                          (not (icharlist< y x)))
                     (equal (icharlisteqv x y) t)))

    Theorem: icharlisteqv-implies-equal-icharlist<-1

    (defthm icharlisteqv-implies-equal-icharlist<-1
            (implies (icharlisteqv x x-equiv)
                     (equal (icharlist< x y)
                            (icharlist< x-equiv y)))
            :rule-classes (:congruence))

    Theorem: icharlisteqv-implies-equal-icharlist<-2

    (defthm icharlisteqv-implies-equal-icharlist<-2
            (implies (icharlisteqv y y-equiv)
                     (equal (icharlist< x y)
                            (icharlist< x y-equiv)))
            :rule-classes (:congruence))

    Theorem: icharlist<-trichotomy-strong

    (defthm icharlist<-trichotomy-strong
            (equal (icharlist< x y)
                   (and (not (icharlisteqv x y))
                        (not (icharlist< y x))))
            :rule-classes ((:rewrite :loop-stopper ((x y)))))