• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
          • Lambda
          • Warrant
          • Defwarrant
          • Badge
          • Lambda$
          • Tame
          • Defbadge
          • Print-cl-cache
          • Introduction-to-apply$
          • Well-formed-lambda-objectp
          • Rewriting-calls-of-apply$-ev$-and-loop$-scions
          • Mixed-mode-functions
          • Explain-giant-lambda-object
          • Gratuitous-lambda-object-restrictions
          • Scion
          • Ilk
          • Ev$
          • Translam
          • Fn-equal
          • Apply$-guard
          • L<
            • Apply$-lambda-guard
            • Apply$-userfn
            • Badge-userfn
            • Defun$
            • Apply$-lambda
          • Loop$
          • Programming-with-state
          • Arrays
          • Characters
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Term
    • Apply$

    L<

    Ordering on naturals or lists of naturals

    The function l< is a straightforward ordering relation that compares two objects, each of which is a natural number or a list of natural numbers. It may be convenient to apply lex-fix to two objects before comparing them with l<. Below are the relevant definitions.

    Function: l<

    (defun l< (x y)
      (declare (xargs :guard (and (lexp x) (lexp y))))
      (or (< (len x) (len y))
          (and (= (len x) (len y))
               (if (atom x) (< x y) (d< x y)))))

    Function: lexp

    (defun lexp (x)
      (declare (xargs :guard t))
      (or (natp x)
          (and (consp x) (nat-listp x))))

    Function: d<

    (defun d< (x y)
      (declare (xargs :guard (and (nat-listp x) (nat-listp y))))
      (and (consp x)
           (consp y)
           (or (< (car x) (car y))
               (and (= (car x) (car y))
                    (d< (cdr x) (cdr y))))))

    Function: lex-fix

    (defun lex-fix (x)
      (declare (xargs :guard t))
      (cond ((atom x) (nfix x))
            (t (nfix-list x))))

    Function: nfix-list

    (defun nfix-list (list)
      (declare (xargs :guard t))
      (if (consp list)
          (cons (nfix (car list))
                (nfix-list (cdr list)))
        nil))