• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
        • Omaps
        • All-by-membership
        • Defset
        • In
        • Primitives
          • Setp
          • Insert
          • Head
            • Tail
            • Sfix
            • Emptyp
          • Subset
          • Mergesort
          • Intersect
          • Union
          • Pick-a-point-subset-strategy
          • Delete
          • Double-containment
          • Difference
          • Cardinality
          • Set
          • Intersectp
        • 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
    • Primitives

    Head

    (head x) returns the smallest element in a set.

    This is like car, but respects the non-set convention and always returns nil for ill-formed sets.

    Definitions and Theorems

    Function: head

    (defun head (x)
      (declare (xargs :guard (and (setp x) (not (emptyp x)))))
      (mbe :logic (car (sfix x))
           :exec (car x)))

    Theorem: head-count

    (defthm head-count
      (implies (not (emptyp x))
               (< (acl2-count (head x))
                  (acl2-count x)))
      :rule-classes ((:rewrite) (:linear)))

    Theorem: head-count-built-in

    (defthm head-count-built-in
      (implies (not (emptyp x))
               (o< (acl2-count (head x))
                   (acl2-count x)))
      :rule-classes :built-in-clause)

    Theorem: head-when-emptyp

    (defthm head-when-emptyp
      (implies (emptyp x)
               (equal (head x) nil)))

    Theorem: head-sfix-cancel

    (defthm head-sfix-cancel
      (equal (head (sfix x)) (head x)))

    Theorem: head-minimal

    (defthm head-minimal
      (implies (<< a (head x))
               (not (in a x))))

    Theorem: head-minimal-2

    (defthm head-minimal-2
      (implies (in a x)
               (not (<< a (head x)))))

    Theorem: head-unique

    (defthm head-unique
      (not (in (head x) (tail x))))