Filtering...

g-integer-length

books/centaur/gl/g-integer-length
other
(in-package "GL")
other
(include-book "g-if")
other
(include-book "g-primitives-help")
other
(include-book "symbolic-arithmetic")
other
(include-book "eval-g-base")
other
(local (include-book "eval-g-base-help"))
other
(local (include-book "hyp-fix"))
other
(set-inhibit-warnings "theory")
other
(def-g-fn integer-length
  `(b* ((x i))
    (if (atom x)
      (gret (ec-call (integer-length x)))
      (pattern-match x
        ((g-ite test then else) (if (zp clk)
            (gret (g-apply 'integer-length (gl-list x)))
            (g-if (gret test)
              (,GL::GFN then . ,GL::PARAMS)
              (,GL::GFN else . ,GL::PARAMS))))
        ((g-apply & &) (gret (g-apply 'integer-length (gl-list x))))
        ((g-var &) (gret (g-apply 'integer-length (gl-list x))))
        ((g-boolean &) (gret 0))
        ((g-concrete obj) (gret (ec-call (integer-length obj))))
        ((g-integer bits) (gret (mk-g-integer (bfr-integer-length-s (list-fix bits)))))
        (& (gret 0))))))
other
(verify-g-guards integer-length
  :hints `(("Goal" :in-theory (disable ,GL::GFN))))
other
(def-gobj-dependency-thm integer-length
  :hints `(("goal" :induct ,GL::GCALL
     :expand (,GL::GCALL)
     :in-theory (disable (:d ,GL::GFN)))))
other
(local (defthm non-integerp-integer-length
    (implies (not (integerp x))
      (equal (integer-length x) 0))
    :rule-classes ((:rewrite :backchain-limit-lst 1))))
other
(local (defthm eval-g-base-booleanp
    (implies (booleanp x)
      (equal (eval-g-base x env) x))
    :hints (("Goal" :in-theory (enable eval-g-base booleanp)))))
other
(local (include-book "arithmetic/top-with-meta" :dir :system))
other
(local (defthm general-concrete-obj-integer
    (implies (integerp x)
      (equal (general-concrete-obj x) x))
    :hints (("Goal" :in-theory (enable general-concrete-obj)))))
other
(local (defthm eval-g-base-integer
    (implies (integerp x)
      (equal (eval-g-base x env) x))
    :hints (("Goal" :in-theory (enable eval-g-base)))))
other
(def-g-correct-thm integer-length
  eval-g-base
  :hints `(("Goal" :in-theory (e/d nil
       ((:definition ,GL::GFN) general-concretep-def
         eval-g-base-alt-def
         integer-length))
     :induct (,GL::GFN i . ,GL::PARAMS)
     :expand ((,GL::GFN i . ,GL::PARAMS))) (and stable-under-simplificationp
      '(:expand ((:with eval-g-base (eval-g-base i env)))))))