Filtering...

itest-ithm

books/acl2s/aspf/interface/acl2s-utils/itest-ithm
other
(in-package "ACL2S")
other
(include-book "itest-cgen")
other
(set-verify-guards-eagerness 1)
itest?-fn1function
(defun itest?-fn1
  (form hints
    override-defaults
    state)
  (declare (xargs :mode :program :stobjs (state)))
  (b* ((ctx 'itest?) (debug-enable (f-get-global 'debugger-enable state))
      (state (f-put-global 'debugger-enable :never state))
      (cgen-state (make-cgen-state-fn form
          (cons :user-defined ctx)
          override-defaults
          (w state)))
      (vl (cget verbosity-level))
      (pts? (cget print-cgen-summary))
      (timeout (cget cgen-timeout))
      (hints (append 'nil
          (add-string-val-pair-to-string-val-alist "Goal"
            :do-not (list 'quote '(generalize fertilize))
            (add-string-val-pair-to-string-val-alist "Goal"
              :do-not-induct t
              hints))))
      ((mv res cgen-state state) (with-time-limit timeout
          (prove/cgen form
            hints
            cgen-state
            state)))
      ((er &) (cond ((not (cgen-state-p cgen-state)) (value nil))
          ((and (<= (access gcs% (cget gcs) :cts) 0)
             (not pts?)) (value nil))
          (t (print-testing-summary cgen-state
              ctx
              state))))
      ((mv cgen-err cts-found? state) (cond ((eq res :falsifiable) (prog2$ (cw? (normal-output-flag vl)
                "~%Itest? found a counterexample.~%")
              (mv nil t state)))
          ((eq res t) (prog2$ (cw? (and pts? (normal-output-flag vl))
                "~|Itest? failed (probably due to a hard error).~%")
              (mv t nil state)))
          ((eq res nil) (prog2$ (cw? (and pts? (normal-output-flag vl))
                "~%Itest? proved the conjecture under consideration~s0. ~
Therefore, no counterexamples exist. ~%"
                (if hints
                  ""
                  " (without induction)"))
              (mv nil nil state)))
          (t (prog2$ (cw? (and pts? (normal-output-flag vl))
                "~%Itest? succeeded. No counterexamples were found.~%")
              (mv nil nil state)))))
      ((er counterexamples) (if cgen-err
          (mv t nil state)
          (extract-cgen cgen-state state)))
      (state (f-put-global 'debugger-enable
          debug-enable
          state)))
    (mv cgen-err
      (list cts-found?
        (cons res counterexamples))
      state)))
itest?-fnfunction
(defun itest?-fn
  (form hints
    override-defaults
    state)
  (declare (xargs :mode :program :stobjs (state)))
  (revert-world (itest?-fn1 form
      hints
      override-defaults
      state)))
itest?-fn-simplefunction
(defun itest?-fn-simple
  (form state)
  (declare (xargs :mode :program :stobjs (state)))
  (itest?-fn form nil nil state))
itest?macro
(defmacro itest?
  (form &rest kwd-val-lst)
  (let* ((vl-entry (assoc-keyword :verbosity-level kwd-val-lst)) (vl (and vl-entry (cadr vl-entry)))
      (debug (and (natp vl) (debug-flag vl)))
      (hints-entry (assoc-keyword :hints kwd-val-lst))
      (hints (and hints-entry (cadr hints-entry))))
    `(with-output :stack :push ,@(IF DEBUG
      '(:ON :ALL :SUMMARY-ON :ALL)
      '(:OFF :ALL :SUMMARY-OFF :ALL))
      ,@(IF DEBUG
      NIL
      (LIST :ON 'ACL2S::COMMENT))
      :gag-mode ,(NOT DEBUG)
      (itest?-fn ',ACL2S::FORM
        ',ACL2S::HINTS
        ',ACL2S::KWD-VAL-LST
        state))))
other
(defconst *hints-no-induct-gen*
  '(:hints (("goal" :do-not-induct t :do-not '(generalize)))))
other
(defconst *hints-no-induct-gen-otf-on*
  `(,@ACL2S::*HINTS-NO-INDUCT-GEN* :otf-flg t))
thm-no-induct-genmacro
(defmacro thm-no-induct-gen
  (f)
  `(thm ,ACL2S::F ,@ACL2S::*HINTS-NO-INDUCT-GEN*))
thm-no-induct-gen-otf-onmacro
(defmacro thm-no-induct-gen-otf-on
  (f)
  `(thm ,ACL2S::F ,@ACL2S::*HINTS-NO-INDUCT-GEN-OTF-ON*))