• 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
        • Candidate-with-least-nth-place-votes
          • Candidates-with-min-votes
            • All-keys
            • Min-nats
            • Pick-candidate-with-smallest-id
          • 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
        • Riscv
        • Bitcoin
        • 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
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Candidates-with-min-votes

    Min-nats

    Pick the minimum number in a list of natural numbers

    Signature
    (min-nats x) → min
    Arguments
    x — Guard (nat-listp x).
    Returns
    min — Type (natp min), given the guard.

    Definitions and Theorems

    Function: min-nats

    (defun min-nats (x)
      (declare (xargs :guard (nat-listp x)))
      (let ((__function__ 'min-nats))
        (declare (ignorable __function__))
        (cond ((atom x) 0)
              ((atom (cdr x)) (lnfix (car x)))
              (t (min (lnfix (car x))
                      (min-nats (cdr x)))))))

    Theorem: natp-of-min-nats

    (defthm natp-of-min-nats
      (implies (and (nat-listp x))
               (b* ((min (min-nats x))) (natp min)))
      :rule-classes (:rewrite :type-prescription))

    Theorem: min-nats-returns-a-member-of-input

    (defthm min-nats-returns-a-member-of-input
      (implies (and (nat-listp x) (consp x))
               (member-equal (min-nats x) x)))