• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
      • Gl
      • Witness-cp
      • Ccg
      • Install-not-normalized
      • Rewrite$
      • Fgl
        • Fgl-rewrite-rules
        • Fgl-function-mode
        • Fgl-object
          • Fgl-object-eval
            • Fgl-env
            • Bools->int
            • Fgl-object-p
            • G-map
            • G-ite
            • G-cons
            • G-concrete
            • G-apply
            • G-integer
            • Fgl-object-equiv
            • G-boolean
            • G-var
            • Fgl-bitvector
            • Fgl-object-kind
            • Summarize-fgl-object
            • Fgl-make-isomorphic
            • Fgl-object-alist
            • Fgl-objectlist
            • Fgl-object-fix
            • Fgl-object-count
          • Fgl-solving
          • Fgl-handling-if-then-elses
          • Fgl-getting-bits-from-objects
          • Fgl-primitive-and-meta-rules
          • Fgl-counterexamples
          • Fgl-interpreter-overview
          • Fgl-correctness-of-binding-free-variables
          • Fgl-debugging
          • Fgl-testbenches
          • Def-fgl-boolean-constraint
          • Fgl-stack
          • Fgl-rewrite-tracing
          • Def-fgl-param-thm
          • Def-fgl-thm
          • Fgl-fast-alist-support
          • Fgl-array-support
          • Advanced-equivalence-checking-with-fgl
          • Fgl-fty-support
          • Fgl-internals
        • Removable-runes
        • Efficiency
        • Rewrite-bounds
        • Bash
        • Def-dag-measure
        • Bdd
        • Remove-hyps
        • Contextual-rewriting
        • Simp
        • Rewrite$-hyps
        • Bash-term-to-dnf
        • Use-trivial-ancestors-check
        • Minimal-runes
        • Clause-processor-tools
        • Fn-is-body
        • Without-subsumption
        • Rewrite-equiv-hint
        • Def-bounds
        • Rewrite$-context
        • Try-gl-concls
        • Hint-utils
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Fgl-object-eval
    • Fgl-bitvector

    Bools->int

    Convert a list of Booleans into an integer.

    Signature
    (bools->int x) → *
    Arguments
    x — Guard (boolean-listp x).

    Produces a two's-complement integer from a list of bits, least-significant first. The last element of the list determines the sign of the value. Some examples:

    • (t) and (t t t) both evaluate to -1
    • nil, (nil), and (nil nil nil) all evaluate to 0
    • (t t t nil) evaluates to 7
    • (nil nil t) evaluates to -4.

    Definitions and Theorems

    Function: bools->int

    (defun bools->int (x)
      (declare (xargs :guard (boolean-listp x)))
      (let ((__function__ 'bools->int))
        (declare (ignorable __function__))
        (mbe :logic
             (if (atom (cdr x))
                 (- (bool->bit (car x)))
               (logcons (bool->bit (car x))
                        (bools->int (cdr x))))
             :exec (cond ((atom x) 0)
                         ((atom (cdr x)) (- (bool->bit (car x))))
                         (t (logcons (bool->bit (car x))
                                     (bools->int (cdr x))))))))

    Theorem: bools->int-of-true-list-fix

    (defthm bools->int-of-true-list-fix
      (equal (bools->int (true-list-fix x))
             (bools->int x)))

    Theorem: bools->int-of-boolean-list-fix-x

    (defthm bools->int-of-boolean-list-fix-x
      (equal (bools->int (acl2::boolean-list-fix x))
             (bools->int x)))

    Theorem: bools->int-boolean-list-equiv-congruence-on-x

    (defthm bools->int-boolean-list-equiv-congruence-on-x
      (implies (acl2::boolean-list-equiv x x-equiv)
               (equal (bools->int x)
                      (bools->int x-equiv)))
      :rule-classes :congruence)