On this page:
alphorder
atom
eq
eql
eqlablep
equal
identity
lexorder
caar
cdar
cadr
cddr
caaar
cdaar
cadar
cddar
caadr
cdadr
caddr
cdddr
caaaar
cdaaar
cadaar
cddaar
caadar
cdadar
caddar
cdddar
caaadr
cdaadr
cadadr
cddadr
caaddr
cdaddr
cadddr
cddddr
quote
quasiquote
unquote
subst
acl2-count
1.4.11 Trees

procedure

(alphorder x y)  t

  x : (atom x)
  y : (atom y)
Determines if x is lexicographically less than y. Works on any atomic input.

Examples:

> (alphorder 6 4)

'()

> (alphorder 4 6)

't

> (alphorder 4 4)

't

> (alphorder "abc" "bcd")

't

> (alphorder "bcd" "abc")

'()

> (alphorder #\a "a")

't

> (alphorder "a" #\a)

'()

procedure

(atom x)  t

  x : t
Returns true if x is not a cons pair.

Examples:

> (atom 4)

't

> (atom 'hello)

't

> (atom (cons 4 nil))

'()

procedure

(eq x y)  t

  x : t
  y : (or (symbolp x) (symbolp y))
Tests two symbols for equality.

Examples:

> (eq 'yes 'yes)

't

> (eq 'yes 'no)

'()

procedure

(eql x y)  t

  x : t
  y : (or (eqlablep x) (eqlablep y))
Tests equality of two numbers, symbols, or characters.

Examples:

> (eql 'yes 'yes)

't

> (eql 'yes 'no)

'()

> (eql 5 5)

't

> (eql #\a #\b)

'()

> (eql #\5 5)

'()

procedure

(eqlablep x)  t

  x : t
Returns t if and only if x is either a number, a symbol, or a character.

Examples:

> (eqlablep nil)

't

> (eqlablep 4)

't

> (eqlablep #\a)

't

> (eqlablep 'symbol)

't

> (eqlablep "string")

'()

syntax

(equal x y)

Tests x and y for equality. Returns t if and only if they are the same value.

Examples:

> (equal "yes" "yes")

't

> (equal 'yes "no")

'()

> (equal 'yes "yes")

'()

procedure

(identity x)  t

  x : t
The identity function. Returns its argument unchanged.

Example:

> (identity 'x)

'x

procedure

(lexorder a b)  t

  a : t
  b : t
Determines if the two given items are in lexicographic order.

Examples:

> (lexorder 6 4)

'()

> (lexorder 4 6)

't

> (lexorder #\a #\b)

't

> (lexorder #\b #\a)

'()

> (lexorder 'a 'b)

't

> (lexorder 'b 'a)

'()

> (lexorder "abc" "bcd")

't

> (lexorder "bcd" "abc")

'()

> (lexorder (list 1 2) (list 3 4))

't

> (lexorder (list 3 4) (list 1 2))

'()

syntax

(caar x)

syntax

(cdar x)

syntax

(cadr x)

syntax

(cddr x)

syntax

(caaar x)

syntax

(cdaar x)

syntax

(cadar x)

syntax

(cddar x)

syntax

(caadr x)

syntax

(cdadr x)

syntax

(caddr x)

syntax

(cdddr x)

syntax

(caaaar x)

syntax

(cdaaar x)

syntax

(cadaar x)

syntax

(cddaar x)

syntax

(caadar x)

syntax

(cdadar x)

syntax

(caddar x)

syntax

(cdddar x)

syntax

(caaadr x)

syntax

(cdaadr x)

syntax

(cadadr x)

syntax

(cddadr x)

syntax

(caaddr x)

syntax

(cdaddr x)

syntax

(cadddr x)

syntax

(cddddr x)

Shorthand macros for compositions of car and cdr. For instance, (caddr x) is equivalent to (car (cdr (cdr x))).

Examples:

> (defconst *tree*
    (cons (cons (cons (cons 0 1) (cons 2 3))
                (cons (cons 4 5) (cons 6 7)))
          (cons (cons (cons 8 9) (cons 10 11))
                (cons (cons 12 13) (cons 14 15)))))

eval:541:0: defconst: defined outside of begin-below

  at: here

  in: (defconst *tree* (cons (cons (cons (cons 0 1) (cons 2

3)) (cons (cons 4 5) (cons 6 7))) (cons (cons (cons 8 9)

(cons 10 11)) (cons (cons 12 13) (cons 14 15)))))

> (caar *tree*)

eval:542:0: application: bad syntax

  in: (top/error . *tree*)

> (cdar *tree*)

eval:543:0: application: bad syntax

  in: (top/error . *tree*)

> (cadr *tree*)

eval:544:0: application: bad syntax

  in: (top/error . *tree*)

> (cddr *tree*)

eval:545:0: application: bad syntax

  in: (top/error . *tree*)

> (caaar *tree*)

eval:546:0: application: bad syntax

  in: (top/error . *tree*)

> (cdaar *tree*)

eval:547:0: application: bad syntax

  in: (top/error . *tree*)

> (cadar *tree*)

eval:548:0: application: bad syntax

  in: (top/error . *tree*)

> (cddar *tree*)

eval:549:0: application: bad syntax

  in: (top/error . *tree*)

> (caadr *tree*)

eval:550:0: application: bad syntax

  in: (top/error . *tree*)

> (cdadr *tree*)

eval:551:0: application: bad syntax

  in: (top/error . *tree*)

> (caddr *tree*)

eval:552:0: application: bad syntax

  in: (top/error . *tree*)

> (cdddr *tree*)

eval:553:0: application: bad syntax

  in: (top/error . *tree*)

> (caaaar *tree*)

eval:554:0: application: bad syntax

  in: (top/error . *tree*)

> (cdaaar *tree*)

eval:555:0: application: bad syntax

  in: (top/error . *tree*)

> (cadaar *tree*)

eval:556:0: application: bad syntax

  in: (top/error . *tree*)

> (cddaar *tree*)

eval:557:0: application: bad syntax

  in: (top/error . *tree*)

> (caadar *tree*)

eval:558:0: application: bad syntax

  in: (top/error . *tree*)

> (cdadar *tree*)

eval:559:0: application: bad syntax

  in: (top/error . *tree*)

> (caddar *tree*)

eval:560:0: application: bad syntax

  in: (top/error . *tree*)

> (cdddar *tree*)

eval:561:0: application: bad syntax

  in: (top/error . *tree*)

> (caaadr *tree*)

eval:562:0: application: bad syntax

  in: (top/error . *tree*)

> (cdaadr *tree*)

eval:563:0: application: bad syntax

  in: (top/error . *tree*)

> (cadadr *tree*)

eval:564:0: application: bad syntax

  in: (top/error . *tree*)

> (cddadr *tree*)

eval:565:0: application: bad syntax

  in: (top/error . *tree*)

> (caaddr *tree*)

eval:566:0: application: bad syntax

  in: (top/error . *tree*)

> (cdaddr *tree*)

eval:567:0: application: bad syntax

  in: (top/error . *tree*)

> (cadddr *tree*)

eval:568:0: application: bad syntax

  in: (top/error . *tree*)

> (cddddr *tree*)

eval:569:0: application: bad syntax

  in: (top/error . *tree*)

syntax

(quote ...)

Examples:

> 'a

'a

> '(1 2 3 4)

'(1 2 3 4)

syntax

(quasiquote ...)

Examples:

> `a

'a

> `(1 2 3 4)

'(1 2 3 4)

syntax

(unquote ...)

Example:

> '(list ,a  b c d)

'(list ,'a b c d)

procedure

(subst new old tree)  t

  new : t
  old : (eqlablep old)
  tree : t
Substitutes every occurrence of old with new in the given tree. Uses eql as the test.

Examples:

> (subst 2 1 (list 1 1 1 3 1 1 1))

'(2 2 2 3 2 2 2)

> (subst 'z 'a (list 'a 'b (list 'd 'a (list 'a 'e)) 'a))

'(z b (d z (z e)) z)

procedure

(acl2-count v)  natp

  v : t
Calculates the size of a value. This is the default recursion metric used for ACL2 termination proofs.

The size of a cons-pair is one more than the sum of the sizes of its car and cdr. The size of an integer is its absolute value, the size of a rational number is the sum of the sizes of its numerator and denominator, and the size of a complex number is one more than the sum of the sizes of its real and imaginary parts. The size of a string is its length. The size of all other values (characters and symbols) is 0.

Examples:

> (acl2-count 3/4)

7

> (acl2-count (complex 3 4))

8

> (acl2-count "ABCD")

4

> (acl2-count 'ABCD)

0

> (acl2-count '(a b c d))

4