• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
        • Fairness-criteria
          • Eliminate-candidates
          • Sum-nats
          • Eliminate-other-candidates
          • Clone-p
            • Adjacent-p
            • Last-place
            • All-head-to-head-competition-loser-p
            • Non-maj-ind-hint
            • Find-condorcet-loser
            • Last-place-elim-ind-hint
          • Candidate-with-least-nth-place-votes
          • Eliminate-candidate
          • First-choice-of-majority-p
          • Candidate-ids
          • Irv
          • Create-nth-choice-count-alist
          • Irv-alt
          • Irv-ballot-p
          • Majority
          • Number-of-candidates
          • List-elements-equal
          • Number-of-voters
        • 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
    • Clone-p

    Adjacent-p

    Signature
    (adjacent-p clone c x) → *
    Arguments
    clone — Guard (natp clone).
    c — Guard (natp c).
    x — Guard (nat-listp x).

    Definitions and Theorems

    Function: adjacent-p

    (defun adjacent-p (clone c x)
      (declare (xargs :guard (and (natp clone)
                                  (natp c)
                                  (nat-listp x))))
      (declare (xargs :guard (no-duplicatesp-equal x)))
      (let ((__function__ 'adjacent-p))
        (declare (ignorable __function__))
        (cond ((endp x) t)
              ((equal (car x) clone)
               (if (cdr x)
                   (equal (car (cdr x)) c)
                 nil))
              ((equal (car x) c)
               (if (cdr x)
                   (equal (car (cdr x)) clone)
                 nil))
              (t (adjacent-p clone c (cdr x))))))

    Theorem: adjacent-p-of-absent-elements

    (defthm adjacent-p-of-absent-elements
      (implies (and (not (member-equal c x))
                    (not (member-equal clone x)))
               (adjacent-p clone c x)))

    Theorem: adjacent-p-reflexive

    (defthm adjacent-p-reflexive
      (implies (adjacent-p c clone x)
               (adjacent-p clone c x)))

    Theorem: remove-equal-preserves-adjacent-p

    (defthm remove-equal-preserves-adjacent-p
      (implies (and (adjacent-p clone c x)
                    (true-listp x)
                    (not (equal id c))
                    (not (equal id clone)))
               (adjacent-p clone c (remove-equal id x))))