Filtering...

truncate-rem

books/arithmetic-5/lib/floor-mod/truncate-rem

Included Books

other
(in-package "ACL2")
local
(local (include-book "../basic-ops/top"))
local
(local (include-book "floor-mod"))
local
(local (include-book "floor-mod-basic"))
include-book
(include-book "../basic-ops/building-blocks")
rewrite-truncate-to-floortheorem
(defthm rewrite-truncate-to-floor
  (implies (syntaxp (rewriting-goal-literal x mfc state))
    (equal (truncate x y)
      (cond ((not (real/rationalp (/ x y))) 0)
        ((<= 0 (/ x y)) (floor x y))
        ((integerp (/ x y)) (/ x y))
        (t (+ 1 (floor x y))))))
  :hints (("Goal" :in-theory (e/d (floor) (nonnegative-integer-quotient)))))
rewrite-rem-to-modtheorem
(defthm rewrite-rem-to-mod
  (implies (syntaxp (rewriting-goal-literal x mfc state))
    (equal (rem x y)
      (cond ((not (real/rationalp (/ x y))) (if (acl2-numberp x)
            x
            0))
        ((<= 0 (/ x y)) (mod x y))
        ((integerp (/ x y)) 0)
        (t (- (mod x y) y)))))
  :hints (("Goal" :in-theory (e/d (mod) (truncate)))))
rewrite-ceiling-to-floortheorem
(defthm rewrite-ceiling-to-floor
  (implies (syntaxp (rewriting-goal-literal x mfc state))
    (equal (ceiling x y)
      (cond ((not (real/rationalp (/ x y))) 0)
        ((integerp (/ x y)) (/ x y))
        (t (+ 1 (floor x y))))))
  :hints (("Goal" :in-theory (e/d (floor) (nonnegative-integer-quotient)))))
rewrite-round-to-floortheorem
(defthm rewrite-round-to-floor
  (implies (syntaxp (rewriting-goal-literal x mfc state))
    (equal (round x y)
      (cond ((not (real/rationalp (/ x y))) (cond ((< 1/2 (/ x y)) 1) ((< (/ x y) -1/2) -1) (t 0)))
        ((< (mod (/ x y) 1) 1/2) (floor x y))
        ((< 1/2 (mod (/ x y) 1)) (+ 1 (floor x y)))
        (t (if (evenp (floor x y))
            (floor x y)
            (+ 1 (floor x y)))))))
  :hints (("Goal" :in-theory (e/d (floor mod) (nonnegative-integer-quotient)))))
ash-to-floortheorem
(defthm ash-to-floor
  (implies (syntaxp (rewriting-goal-literal i mfc state))
    (equal (ash i n)
      (cond ((and (integerp i) (integerp n)) (floor i (expt 2 (- n))))
        ((integerp i) i)
        (t 0))))
  :hints (("Goal" :in-theory (e/d (floor) (nonnegative-integer-quotient)))))
in-theory
(in-theory (disable truncate rem ceiling round ash))