; Problem Set 4 ; To do this problem set you should take your copy of m1-story.lisp and make a ; copy of everything from the top through the defun of compile. Save that ; fragment of m1-story.lisp as problem-set-4-answers.lisp. Then edit it to ; answer these two questions. By the way, it is very common in software ; development that you are asked to take an existing system and modify it! ; Problem 4-1: Extend M1 so that it supports the IFNE instruction. The ; semantics of (IFNE x) is that it adds x to the pc if the top of the stack is ; not equal to 0; otherwise control passes to the next instruction. In any case, ; the topmost item on the stack is removed. ; Problem 4-2: Change the M1 compiler to support two new features: ; a new test, namely the equality of two integer-valued expressions, ; and an IF statement. In particular the two syntactic changes ; are ; := ( > ) | ( = ) ; := ( = ) | ; ( while ) | ; ( if ( ) ; ( ) ) | ; ( return ) ; where: ; the semantics of the new , ( = ), is that it is true if ; the two s evaluate to the same integer and false otherwise. You may ; assume that all s evaluate to integers; and ; the semantics of ( if ( ) ( ) ) is that if ; evaluates to true the first sequence of statements is evaluated, otherwise ; the second is evaluated. ; I strongly advise you to test your compiler, but that is not necessary for ; full credit. ; Obscure Hint: ACL2 will probably have trouble admitting your modified version ; of collect-vars-in-stmt*, collect-vars-in-stmt, stmt*! and stmt!. That is ; because it doesn't know this simple fact: ; (defthm hack-lemma ; (implies (car stmt) ; (consp stmt))) ; I advise you to insert this lemma in your script just before the ; mutual-recursion event defining collect-vars-in-stmt*.