• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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$
        • Loop$
          • Loop$-primer
            • Lp-section-8
            • Lp-section-10
            • Lp-section-6
            • Lp-section-9
            • Lp-section-17
            • Lp-section-16
            • Lp-section-15
            • Lp-section-11
            • Lp-section-4
            • Lp-section-7
            • Lp-section-13
            • Lp-section-12
            • Lp-section-14
            • Lp-section-5
            • Lp-section-0
            • Lp-section-2
            • Lp-section-18
            • Lp-section-3
            • Lp-section-1
              • Lp-background-review-2-answers
              • Lp-background-review-1-answers
              • Lp-background-review-1
                • Lp-background-review-2
            • Do-loop$
            • For-loop$
            • Loop$-recursion
            • Stating-and-proving-lemmas-about-loop$s
            • Loop$-recursion-induction
            • Do$
          • Programming-with-state
          • Arrays
          • Characters
          • Time$
          • Defconst
          • Defmacro
          • Loop$-primer
            • Lp-section-8
            • Lp-section-10
            • Lp-section-6
            • Lp-section-9
            • Lp-section-17
            • Lp-section-16
            • Lp-section-15
            • Lp-section-11
            • Lp-section-4
            • Lp-section-7
            • Lp-section-13
            • Lp-section-12
            • Lp-section-14
            • Lp-section-5
            • Lp-section-0
            • Lp-section-2
            • Lp-section-18
            • Lp-section-3
            • Lp-section-1
              • Lp-background-review-2-answers
              • Lp-background-review-1-answers
              • Lp-background-review-1
                • Lp-background-review-2
            • Fast-alists
            • Evaluation
            • Guard
            • Equality-variants
            • Compilation
            • Hons
            • ACL2-built-ins
              • Let
              • Declare
              • Mbe
              • Apply$
              • Fmt
              • Loop$
                • Loop$-primer
                  • Lp-section-8
                  • Lp-section-10
                  • Lp-section-6
                  • Lp-section-9
                  • Lp-section-17
                  • Lp-section-16
                  • Lp-section-15
                  • Lp-section-11
                  • Lp-section-4
                  • Lp-section-7
                  • Lp-section-13
                  • Lp-section-12
                  • Lp-section-14
                  • Lp-section-5
                  • Lp-section-0
                  • Lp-section-2
                  • Lp-section-18
                  • Lp-section-3
                  • Lp-section-1
                    • Lp-background-review-2-answers
                    • Lp-background-review-1-answers
                    • Lp-background-review-1
                      • Lp-background-review-2
                  • Do-loop$
                  • For-loop$
                  • Loop$-recursion
                  • Stating-and-proving-lemmas-about-loop$s
                  • Loop$-recursion-induction
                  • Do$
                • Return-last
                • Mv-let
                • Df
                • Pseudo-termp
                • Defwarrant
                • Time$
                • Mbt
                • Ec-call
                • Mv-nth
                • Sys-call
                • Msg
                • Er
                • Value-triple
                • O-p
                • Comp
                • Member
                • O<
                • Cw
                • Flet
                • Or
                • Hons
                • Cbd
                • Mv
                • Defbadge
                • Append
                • *ACL2-exports*
                • Comment
                • Eql
                • List
                • Unsigned-byte-p
                • Posp
                • Natp
                • The
                • Nth
                • And
                • Len
                • Time-tracker
                • Term-order
                • True-listp
                • Msgp
                • Booleanp
                • <
                • If
                • Pseudo-term-listp
                • +
                • Not
                • With-global-stobj
                • Bitp
                • Equal
                • Cdr
                • Car
                • String-listp
                • Nat-listp
                • Implies
                • Iff
                • Character-listp
                • Alistp
                • Cons
                • Symbol-listp
                • Macrolet
                • Quote
                • Integerp
                • Consp
                • True-list-listp
                • State-global-let*
                • Compress1
                • Symbolp
                • Stringp
                • *common-lisp-symbols-from-main-lisp-package*
                • Characterp
                • Prog2$
                • *
                • Last-prover-steps
                • Hons-acons
                • Let*
                • Eq
                • With-guard-checking
                • @
                • Length
                • With-local-stobj
                • Hard-error
                • -
                • Zp
                • Search
                • Intersection$
                • Assign
                • Aset1
                • Symbol-name
                • Union$
                • Set-gc-strategy
                • In-tau-intervalp
                • Cons-with-hint
                • Break-on-error
                • Pand
                • Case-match
                • Fast-alist-fork
                • Sys-call+
                • Signed-byte-p
                • ACL2-count
                • Remove-duplicates
                • With-serialize-character
                • Observation
                • Hons-resize
                • Make-tau-interval
                • Assoc
                • Logbitp
                • Termp
                • Position
                • *standard-co*
                • Hons-acons!
                • Update-nth
                • Aref1
                • Symbol-alistp
                • Read-run-time
                • Take
                • Symbol-package-name
                • Hons-wash
                • Keywordp
                • Expt
                • Coerce
                • Get-internal-time
                • Intern
                • Non-exec
                • Case
                • Standard-oi
                • Standard-co
                • Formula
                • Atom
                • Without-evisc
                • Good-bye
                • Ash
                • With-local-state
                • Spec-mv-let
                • Intern-in-package-of-symbol
                • Binary-+
                • <=
                • With-fast-alist
                • Set-difference$
                • Hons-clear
                • Flush-compress
                • Rationalp
                • Por
                • Rassoc
                • Logand
                • Remove-assoc
                • =
                • Nthcdr
                • Pargs
                • Nfix
                • Hons-copy
                • Alphorder
                • Subsetp
                • Floor
                • Remove1-assoc
                • No-duplicatesp
                • Mv-list
                • Canonical-pathname
                • Aset2
                • Serialize-read
                • Random$
                • Fmt-to-comment-window
                • F-put-global
                • Compress2
                • Concatenate
                • Fast-alist-clean
                • Assert$
                • Remove
                • Remove1
                • Intersectp
                • Endp
                • Put-assoc
                • Princ$
                • Primitive
                • Keyword-value-listp
                • True-list-fix
                • Swap-stobjs
                • Integer-listp
                • Illegal
                • Hons-get
                • With-output-lock
                • Setenv$
                • Open-output-channel!
                • Fast-alist-free
                • Er-progn
                • Cw-print-base-radix
                • Reverse
                • Cond
                • Complex
                • Add-to-set
                • Truncate
                • Digit-char-p
                • Code-char
                • Char-code
                • Set-print-case
                • Set-print-base
                • Read-ACL2-oracle
                • Error1
                • Print-object$
                • Plet
                • Logior
                • Integer-length
                • Zip
                • With-live-state
                • Hons-assoc-equal
                • Extend-pathname
                • In-package
                • With-guard-checking-event
                • Term-listp
                • Print-object$+
                • Fmx-cw
                • String
                • Mod
                • Unary--
                • Set-print-radix
                • Resize-list
                • Pkg-witness
                • Revappend
                • Null
                • Term-list-listp
                • Make-fast-alist
                • Header
                • Boole$
                • Subseq
                • Logxor
                • With-guard-checking-error-triple
                • /
                • Make-list
                • Char-upcase
                • Char-downcase
                • Strip-cars
                • Set-fmt-hard-right-margin
                • Make-ord
                • Ifix
                • Fast-alist-free-on-exit
                • F-get-global
                • Aref2
                • Standard-char-p
                • Lognot
                • Must-be-equal
                • Integer-range-p
                • Getenv$
                • Binary-append
                • Er-hard
                • Eqlablep
                • Cpu-core-count
                • Boolean-listp
                • Allocate-fixnum-range
                • ACL2-numberp
                • Butlast
                • Pairlis$
                • Mod-expt
                • Hons-equal
                • Gc$
                • Substitute
                • Ceiling
                • With-stolen-alist
                • Mv?-let
                • String-upcase
                • String-downcase
                • Round
                • Count
                • Char
                • Sys-call-status
                • Progn$
                • Pprogn
                • Lexorder
                • Hons-summary
                • Break$
                • Assert*
                • Alpha-char-p
                • Strip-cdrs
                • Serialize-write
                • Keyword-listp
                • Upper-case-p
                • Lower-case-p
                • Logeqv
                • List*
                • Last
                • Proofs-co
                • Maximum-length
                • Fix
                • Explode-nonnegative-integer
                • Eqlable-listp
                • Dimensions
                • Default
                • Arity
                • Sublis
                • Max
                • Evenp
                • Explode-atom
                • Change
                • Zerop
                • String<
                • String-equal
                • Abs
                • Set-print-base-radix
                • Print-base-p
                • Nonnegative-integer-quotient
                • Intern$
                • Getprop
                • Binary-*
                • Aset1-trusted
                • Symbol<
                • String-append
                • Rfix
                • Mv?
                • Logic-fns-list-listp
                • Fast-alist-fork!
                • Er-hard?
                • Char-equal
                • 1+
                • *standard-oi*
                • Sys-call*
                • Pos-listp
                • Mbt*
                • Hons-wash!
                • Hons-clear!
                • Signum
                • Rem
                • Real/rationalp
                • Rational-listp
                • O-first-coeff
                • Logic-fnsp
                • Logic-fns-listp
                • Hons-copy-persistent
                • Gc-strategy
                • Fast-alist-summary
                • String>=
                • String<=
                • Acons
                • O-first-expt
                • Fast-alist-clean!
                • >=
                • >
                • Subst
                • Logcount
                • Getpropc
                • Evens
                • Er-soft
                • Digit-to-char
                • Comp-gcl
                • Atom-listp
                • Arities-okp
                • ACL2-number-listp
                • /=
                • Cadr
                • *standard-ci*
                • Unary-/
                • The-true-list
                • Realfix
                • O-rst
                • Fast-alist-len
                • Complex/complex-rationalp
                • Array2p
                • Array1p
                • Logtest
                • Logandc1
                • Char<
                • Trace-co
                • Putprop
                • Get-real-time
                • Eqlable-alistp
                • Count-keys
                • Assoc-string-equal
                • Logorc1
                • Logandc2
                • Denominator
                • 1-
                • Packn
                • Logic-termp
                • Logic-term-list-listp
                • Fmt!
                • Fms
                • Cw!
                • Assoc-keyword
                • String>
                • Numerator
                • Logorc2
                • Lognor
                • Char>=
                • Update-nth-array
                • The-number
                • Odds
                • Makunbound-global
                • Make-character-list
                • Make
                • List$
                • Int=
                • Get-cpu-time
                • Fmt-to-comment-window!
                • Fms!
                • F-boundp-global
                • Complex-rationalp
                • Alist-to-doublets
                • Access
                • Min
                • Lognand
                • Listp
                • Identity
                • Char>
                • Char<=
                • Zpf
                • Standard-char-listp
                • O-finp
                • Number-subtrees
                • Logic-term-listp
                • Last-cdr
                • Fmt1!
                • Fmt-to-comment-window!+
                • Character-alistp
                • Oddp
                • Minusp
                • Imagpart
                • Conjugate
                • Xor
                • Unquote
                • String-alistp
                • Packn-pos
                • Maybe-flush-and-compress1
                • Kwote
                • Fmt1
                • Fmt-to-comment-window+
                • Cw-print-base-radix!
                • Alist-keys-subsetp
                • Realpart
                • Plusp
                • First
                • Symbol-name-lst
                • R-symbol-alistp
                • R-eqlable-alistp
                • Fmx
                • Cw!+
                • Cons-subtrees
                • Cons-count-bounded
                • Cddr
                • Caar
                • Proper-consp
                • Kwote-lst
                • Improper-consp
                • Cw+
                • Rest
                • Standard-char-p+
                • Mbe1
                • Caddr
                • Pairlis-x2
                • Pairlis-x1
                • O>=
                • O<=
                • O-infp
                • Merge-sort-lexorder
                • Fix-true-list
                • Cdddr
                • Set-fmt-soft-right-margin
                • Real-listp
                • O>
                • Cddar
                • Cdar
                • Cdadr
                • Cdaar
                • Cadar
                • Caadr
                • Caaar
                • Cadddr
                • Caddar
                • Third
                • Tenth
                • Sixth
                • Seventh
                • Second
                • Ninth
                • Fourth
                • Fifth
                • Eighth
                • Cddddr
                • Cdddar
                • Cddadr
                • Cddaar
                • Cdaddr
                • Cdadar
                • Cdaadr
                • Cdaaar
                • Cadadr
                • Cadaar
                • Caaddr
                • Caadar
                • Caaadr
                • Caaaar
                • Hons-shrink-alist!
                • Hons-shrink-alist
                • Flush-hons-get-hash-table-link
                • Delete-assoc
              • 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
        • Lp-section-1

        Lp-background-review-1

        Background review of basic ACL2 knowledge

        Here are some questions to review basic features of ACL2.

        ——————————

        Consider the expression below and answer the following questions about it, without running ACL2! We're looking for informal answers largely in agreement with ours, not perfect answers. If you want to see the questions together with our answers, see lp-background-review-1-answers.

        (defun abc (x)
          (declare (xargs :mode :program
                          :guard (true-listp x)))
          (cond
           ((endp x) nil)
           (t (cons (cons '? (car x))
                    (abc (cdr x))))))
        ——————————

        1: Informally, what happens if you type that expression at the top-level of the ACL2 read-eval-print loop?

        ——————————

        2: More formally, how does the utterance above affect the ACL2 logic?

        ——————————

        3: A little bit of Lisp knowledge will tell you that all terms are either variables, constants (usually quoted), or calls of functions, where calls are of the form (fn a1 ... an), where fn is a function symbol or lambda object that takes n arguments and the ai are terms. But the cond expression above is not of this form. Cond is a macro that translates into a formal term. What formal term does it translate to? And if you didn't know, how would you find out?

        ——————————

        4: Let x be the object that prints as ((A . 1) (B . 2) (C . 3)). What is the value of (car x) or is that a nonsensical question? Several of the questions below are nonsensical!

        ——————————

        5: Given the value of x in question 4, what is the value of (true-listp x)?

        ——————————

        6: Given the value of x in question 4, what is the value of (cons '? (car x))?

        ——————————

        7: Given the value of x in question 4, what is the value of (cdr x)?

        ——————————

        8: Recall we defined abc above. What is the value (abc '((a . 1) (b . 2) (c . 3)))?

        ——————————

        9: What is the difference between '((a . 1) (b . 2) (c . 3)) and ((A . 1) (B . 2) (C . 3))?

        ——————————

        10: What is the value of (abc ((a . 1) (b . 2) (c . 3)))?

        ——————————

        11: How would you explain what abc is, i.e., how it “works” or what it “does?”

        ——————————

        12: What is the value of (abc 3 4 5)?

        ——————————

        13: What is the value of (abc '(3 . 4))?

        ——————————

        14: How do you get ACL2 to print the value of (abc '(3 . 4))?

        ——————————

        15: How can you upgrade abc from a :program mode function to a :logic mode function?

        ——————————

        16: What is the axiom added to ACL2 when abc is upgraded?

        ——————————

        17: Is (true-listp (abc x)) a theorem in ACL2?

        ——————————

        18: What would you type to get ACL2 to try to prove it?

        ——————————

        19: How would you describe the behavior of the :logic function def below? By the way, we're naming certain functions in these reviews with consecutive letters of the alphabet, e.g., abc, def, ghi, jkl, mno, etc. These names are not mnemonic or acronyms. Don't read anything into the names!

        (defun def (x)
          (if (endp x)
              nil
              (append (def (cdr x)) (list (car x)))))
        ——————————

        20: Define sq to square a number. E.g., (sq 9) returns 81 and (sq -1/2) returns 1/4.

        ——————————

        21: How would you describe the behavior of sq* below?

        (defun sq* (x)
          (if (endp x)
              nil
              (cons (sq (car x))
                    (sq* (cdr x)))))
        ——————————

        22: What would you type to make ACL2 prove the following conjecture?

        (equal (sq* (def x)) (def (sq* x)))
        ——————————

        23: Prove (nat-listp (ghi 0 max)), where

        (defun ghi (i max)
          (declare (xargs :measure (nfix (- (+ 1 (nfix max)) (nfix i)))))
          (let ((i (nfix i))
                (max (nfix max)))
            (cond ((> i max) nil)
                  (t (cons i (ghi (+ 1 i) max))))))
        ——————————

        For our answers see lp-background-review-1-answers. If your answers don't basically agree with ours, you're probably not yet ready to read this material on loop$. We recommend that you read the topic, recursion-and-induction.

        If your answers largely agree with ours, go back to the lp-section-1.

        (Return to the Table of Contents.)