3
Copyright: (c) 2005 Galois Connections, Inc.
4
Author: Lee Pike, Galois Connections, Inc. <leepike@galois.com>
10
(include-book "source_shallow")
13
; (include-book "super-ihs" :dir :super-ihs)
14
(include-book "coi/super-ihs/super-ihs" :dir :system)
17
(defun log-rep-hlp (x i)
18
(let ((val (if (logbitp i x) T NIL)))
20
(cons val (log-rep-hlp x (- i 1))))))
22
;; Lil' endian representation of x.
24
(let ((size (nbits x)))
25
(if (zp size) (list NIL)
26
(reverse (log-rep-hlp x (- size 1))))))
28
(defun nat-rep-hlp (bin-list i)
30
(let ((val (if (nth i bin-list) 1 0)))
34
(nat-rep-hlp bin-list (- i 1)))))))
36
(defun nat-rep (bin-lst)
37
(nat-rep-hlp bin-lst (- (len bin-lst) 1)))
39
;; Helper needed by iterators yielding bits
40
(defun c-update-bit (i b w)
41
(let ((hi-bits (logtail (+ i 1) w)))
42
(logapp i w (logapp 1 b hi-bits))))
45
(defthmd loghead-0 (equal (loghead 0 i) 0))
48
(implies (and (natp i)
53
(equal (loghead n (c-word-- m i k))
55
:hints (("Goal" :in-theory (enable c-word--))))
57
(defthm nat-rep-loghead-1
62
(equal (loghead 1 i) 1))))
65
(defthm less-loghead-expt
66
(< (loghead j i) (expt2 j))
67
:hints (("Goal" :in-theory (enable loghead-when-i-is-not-an-integerp))))