• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/io
      • Std/osets
      • Std/system
      • Std/basic
        • Maybe-stringp
        • Maybe-natp
        • Two-nats-measure
        • Impossible
        • Nat-list-measure
        • Bytep
        • Maybe-posp
        • Nibblep
        • Mbt$
        • Organize-symbols-by-pkg
        • Organize-symbols-by-name
        • Good-valuep
        • Lnfix
          • Streqv
          • Chareqv
          • Symbol-package-name-non-cl
          • Std/basic-extensions
          • Arith-equivs
          • Induction-schemes
          • Maybe-integerp
          • Char-fix
          • Symbol-package-name-lst
          • Pos-fix
          • Maybe-bitp
          • Good-pseudo-termp
          • Str-fix
          • Maybe-string-fix
          • Lifix
          • Bfix
          • Std/basic/if*
          • Impliez
          • Tuplep
          • Std/basic/symbol-name-lst
          • Std/basic/intern-in-package-of-symbol
          • Lbfix
          • True
          • Std/basic/member-symbol-name
          • False
        • 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
    • Std/basic

    Lnfix

    (lnfix x) is logically identical to (nfix x), but its guard requires that x is a natural number and, in the execution, it is just a no-op that returns x.

    (lnfix x) is an inlined, enabled function that just expands into

    (mbe :logic (nfix x) :exec x)

    Why would you want this? When you defining a function whose guard assumes (natp n), it is often a good idea to write the function so that it logically treats non-naturals as 0. You might generally accomplish this by rewriting, e.g.,:

    (defun my-function (n ...)
      (declare (xargs :guard (natp n)))
      <body>)
    
    --->
    
    (defun my-function (n ...)
      (declare (xargs :guard (natp n)))
      (let ((n (nfix n)))
        <body>))

    This leads to a nice nat-equiv congruence rule. But since nfix has to check whether its argument is a natural number, and that has some performance cost.

    By using lnfix in place of nfix here, you can get the same logical definition without this overhead.

    Definitions and Theorems

    Function: lnfix$inline

    (defun lnfix$inline (x)
           (declare (xargs :guard (natp x)))
           (mbe :logic (nfix x) :exec x))