0

I need to try and show a function that finds the minimum of a list works and I fell like I'm close to getting it but can't actually get it.

The instructor gives us this function:

(defun minlist (l)
  (if (<= (len l) 1)
    (first l)
    (if (<= (first l) (minlist (rest l)))
      (first l)
      (minlist (rest l)))))

And then says

;;; TODO: Write a little theory that verifies that the minlist of a list is 
;;; less than or equal to any element of the list
;;; Hint: Use this declaration to generate a non-empty list
;;;  (n :value (random-between 1 10)
;;;   l :value (random-natural-list-of-length n))    

Which I then did:

(defproperty-program minlist-<=-member (n)
    (if ((n :value (random-between 1 10) 
          l :value (random-natural-list-of-length n)))
          (<= (min-list l) (first l))
          (nil)))

Which in Proof Pad gives me an error and I cannot figure out what I've done wrong.

The Error is:

HARD ACL2 ERROR: Missing :value parameter for N

ACL2 Error in TOP-LEVEL: In the attempt to macroexpand the form

(EXPAND-VARS (N)
             (IF ((N :VALUE (RANDOM-BETWEEN 1 10)
                     L
                     :VALUE (RANDOM-NATURAL-LIST-OF-LENGTH N)))
                 (<= (MIN-LIST L) (FIRST L))
                 (NIL))),

evaluation of the macro body caused the following error:

Evaluation aborted. To debug see :DOC print-gv, see :DOC trace, and see :DOC wet.

tswiggy
  • 11
  • 3
  • To help people answer your question, you'll need to be more specific about the error. Please [edit] your post to incorporate the exact errors you get from your [mcve] (preferably using copy+paste to avoid transcription errors). – Toby Speight Oct 16 '17 at 17:17
  • @TobySpeight I have added the error to it – tswiggy Oct 16 '17 at 17:28

1 Answers1

1

I am sorry if this post comes too late.

So I am seeing a few "structure" issues with the defproperty that you have, one is that you call min-list (<= (MIN-LIST L), but the function defined about is minlist without a dash. Also, the portion (n :value (random-between 1 10) l :value (random-natural-list-of-length n))

Constructs the lists to be used, and should not be in the if statement at all. It should be above it. Also, that statement declares the n value, and you do not need the (n) you have. After these changes you end up with

   (defproperty-program minlist-<=-member
(n :value (random-between 1 10) 
          l :value (random-natural-list-of-length n))
    (if (<= (minlist l) (first l))
          (nil)))

But this leaves your if statement without enough arguments. Also, the statement you have '(<= (minlist l) (first l))' only checks to see if the first element of the list is smaller or equal to the minlist element. this does not prove it is smaller than the other elements that may exists.

I hope this helps.