Midterm Exam 2 CS313K Logic, Sets, and Functions Spring, 2009

Similar documents
Logic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009

Improving Eliminate-Irrelevance for ACL2

Induction Schemes. Math Foundations of Computer Science

A Tool for Simplifying ACL2 Definitions

MIDTERM EXAMINATION - CS130 - Spring 2005

Homework 1. Notes. What To Turn In. Unix Accounts. Reading. Handout 3 CSCI 334: Spring, 2017

Reasoning About Programs Panagiotis Manolios

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

Orc and ACL2. Nathan Wetzler May 4, University of Texas, Austin

Reasoning About Programs Panagiotis Manolios

An Industrially Useful Prover

Recursion and Induction

Backtracking and Induction in ACL2

Lisp. Versions of LISP

Imperative, OO and Functional Languages A C program is

by the evening of Tuesday, Feb 6

AXIOMS FOR THE INTEGERS

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

May, 2008 (updated, April, 2018)

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

Introduction to ACL2. CS 680 Formal Methods for Computer Verification. Jeremy Johnson Drexel University

Development of a Translator from LLVM to ACL2

Reasoning About Programs Panagiotis Manolios

A Mechanically Checked Proof of the Correctness of the Boyer-Moore Fast String Searching Algorithm

CS 170, Spring 2000 Midterm #1 Professor M. Clancy

Milawa an extensible proof checker

A User s Manual for an Interactive Enhancement to the Boyer-Moore Theorem Prover

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Homework 1. Reading. Problems. Handout 3 CSCI 334: Spring, 2012

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

Final Exam Math 38 Graph Theory Spring 2017 Due on Friday, June 2, at 12:50 pm. Good Luck!!

Mechanized Operational Semantics

Finite Set Theory. based on Fully Ordered Lists. Jared Davis UT Austin. ACL2 Workshop 2004

Propositional Logic Formal Syntax and Semantics. Computability and Logic

CSE Programming Languages Midterm - Winter 2010

Progress Report: Term Dags Using Stobjs

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

CS 373: Combinatorial Algorithms, Spring 1999

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Mathematically Rigorous Software Design Review of mathematical prerequisites

CIS 500: Software Foundations

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Recursively Defined Functions

Intro. Scheme Basics. scm> 5 5. scm>

Date: 16 July 2016, Saturday Time: 14:00-16:00 STUDENT NO:... Math 102 Calculus II Midterm Exam II Solutions TOTAL. Please Read Carefully:

MIDTERM EXAMINATION - CS130 - Spring 2003

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

15 212: Principles of Programming. Some Notes on Continuations

Indicate the option which most accurately completes the sentence.

ITEC2620 Introduction to Data Structures

CS 125 Section #4 RAMs and TMs 9/27/16

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

Mechanized Operational Semantics

2. CONNECTIVITY Connectivity

Scheduling, Map Coloring, and Graph Coloring

Summary of Course Coverage

CIS 500 Software Foundations Midterm I

Sample Final Exam Questions

Problem Set 2 Solutions

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Midterm 1

Math 355: Linear Algebra: Midterm 1 Colin Carroll June 25, 2011

Problem Set 4: Streams and Lazy Evaluation

Parameterized Congruences in ACL2

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8

CS1800 Discrete Structures Final Version A

This should prevent residual sexism, racism, favoritism lurking in the unconscious of your professor & TA from biasing grading!!

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

CSE505, Fall 2012, Midterm Examination October 30, 2012

2 Chapter 4 driver and the state changes induced by each instruction (in terms of certain still undened bit-level functions such as the 8-bit signed a

An Executable Model for JFKr

15 150: Principles of Functional Programming Some Notes on Regular Expression Matching

Proving Theorems about Java and the JVM

UMBC CMSC 331 Final Exam

Answer Key #1 Phil 414 JL Shaheen Fall 2010

CS 320 Homework One Due 2/5 11:59pm

CIS 500: Software Foundations

CSE 331 Final Exam 6/5/17. Name UW ID#

CS 61A, Fall, 2002, Midterm #2, L. Rowe. 1. (10 points, 1 point each part) Consider the following five box-and-arrow diagrams.

CS 173 [A]: Discrete Structures, Fall 2012 Homework 8 Solutions

CIS4/681 { Articial Intelligence 2 > (insert-sort '( )) ( ) 2 More Complicated Recursion So far everything we have dened requires

CSE 341 : Programming Languages Midterm, Spring 2015

My dear students, Believe in yourselves. Believe in your abilities. You can DO this! -Dr. M

Symbolic Programming. Dr. Zoran Duric () Symbolic Programming 1/ 89 August 28, / 89

Introduction to L A TEX for MCS-236

Lecture : Topological Space


CH 87 FUNCTIONS: TABLES AND MAPPINGS

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

Induction in Coq. Nate Foster Spring 2018

ACL2: A Program Verifier for Applicative Common Lisp. Matt Kaufmann - AMD, Austin, TX J Strother Moore UT CS Dept, Austin, TX

Introduction to Term Rewrite Systems and their Applications

CPSC 121 Midterm 1 Friday October 14th, Signature: Section (circle one): 11:00 15:30 17:00

Midterm Examination (Sample Solutions), Cmput 325

Euler's formula and Platonic solids

Design and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶

Transcription:

Your Name: Your EID: Circle Your Discussion Section: 54075: Ian Wehrman, Friday, 9:00 10:00a, ENS 109 54080: Ian Wehrman, Friday, 10:00 11:00a, GSB 2.122 54085: David Rager, Friday, 10:00 11:00a, JES A218A 54088: Behnam Robatmili, Friday, 12:00 1:00p, RLM 5.122 54090: Behnam Robatmili, Friday, 1:00 2:00p, CBA 4.344 54095: Nathan Wetzler, Friday, 1:00 2:00p, JES A209A Instructions Midterm Exam 2 CS313K Logic, Sets, and Functions Spring, 2009 Write your name and EID above and circle the unique ID of your discussion section! Write your answers in the space provided. If your proofs fill more than the space provided, you may write on the back of the page but please put PTO ( please turn over ) at the bottom and put the Question number at the top of each back page you use. If you use extra paper, be sure to put your name and EID and the Question number on each page! There are 10 questions worth a total of 200 points. Those requiring proofs are worth more than those not requiring proofs. Partial credit will be given, so do your best on each question. You have until 5:00 pm. The functions app, tp ( true-listp ), and mem, which have all been used in class, are the familiar functions of those names but I ve included their definitions on the last page of the exam for your reference. Assume you don t know anything about the function symbols P, Q, f, g, and h except whatever is said about them in the statement of each problem. You may refer to the course notes (the red book) during the exam. You may refer to your own notes if they are on paper. No computers are allowed. No talking is allowed. No cellphones. Remove sunglasses, hats, baseball caps, etc. The last section of the exam has no questions. It just lists the defuns of app, tp, and mem. i

Question 1 (10 points): Suppose this is a theorem: T1: (P x y) (f (g x) y) = (f x y). Then is the following a theorem? ((Q (f a a)) (P a a)) (Q (f (g a) a)) Circle the correct answer: yes no Question 2 (10 points): Suppose this is a theorem: T1: ((P x) (P y)) ((Q (f x y)) (Q y)) Then is the following a theorem? ((P a) (Q a)) (Q (f a b)) Circle the correct answer: yes no Question 3 (10 points): Suppose this is a theorem (same T1 as above): T1: ((P x) (P y)) ((Q (f x y)) (Q y)) Then is the following a theorem? ((P a) (Q a)) (Q (f a a)) Circle the correct answer: yes no ii

Question 4 (10 points): Suppose this is a theorem: T1: ((natp x) (P y)) ((Q (f x y)) (Q y)) Then is the following a theorem? (( (Q b)) (Q (f 23 b))) (P b) Of course, natp is the familiar function of that name from the notes. Circle the correct answer: yes no Question 5 (10 points): Suppose we want to prove (consp x) (mem e x) by induction. Is this a legal induction argument? Base: (consp x) ((consp x) (mem e x)) Induction Step: ((consp x) (mem e (cdr x))) (mem e x). Circle the correct answer: yes no iii

Question 6 (20 points): Show a proof of or a counterexample to the following: ((A (B C)) (B D) ((D C) E)) ((A Q) E) iv

Question 7 (30 points): Show a proof of or a counterexample to the following: (tp (app nil a)). v

Question 8 (30 points): Show a proof of or a counterexample to the following: (e d) ((mem e (cons d x)) (mem e x)). vi

Question 9 (35 points): Suppose h is defined as follows: (defun h (x y) (if (endp x) y (h (cdr x) y))) Show a proof of or a counterexample to the following: (h x y) = y. vii

Question 10 (35 points): Suppose P23 is defined as follows: (defun P23 (x) (if (endp x) t (if (equal (car x) 23) (P23 (cdr x)) nil))) You may assume the following four simple theorems about P23 and app. These follow easily from the definitions of P23 and app. T1: (consp x) ((P23 x) t) T2: (consp x) ((P23 x) ((car x)=23 (P23 (cdr x)))) T3: (consp x) (app x y)=y T4: (consp x) (app x y) = (cons (car x) (app (cdr x) y)) Below is a proof of the formula ((P23 a) (P23 b)) (P23 (app a b)). Fill in the space between the braces {...} to explain each step. Some steps represent the application of several rules. You may omit uses of Rewriting with the Basic, Short Circuit, and Associativity of tautologies. But you should list every application of the following rules: Rewriting with Promotion or Forward Chain, Rewriting with the definitions of P23 or app, Rewriting with the theorems T1, T2, T3, or T4, use of the Hyp rule for hypothesis i, and use of Cases. If you get to an illegal step, just say so and don t go any further. Each formula below is well-formed, so don t worry about checking the parentheses etc. Partial credit will be given, so explain all the steps you can. viii

Theorem ((P23 a) (P23 b)) (P23 (app a b)). Proof {Induct on... } ( name the induction variable and show σ) Base Case: [ (consp a) (((P23 a) (P23 b)) (P23 (app a b)))] [( (consp a) (P23 a) (P23 b)) (P23 (app a b))] [( (consp a) (P23 b)) (P23 b)] T [( (consp a) (P23 b)) T] (Proof continued on next page.) ix

Induction Step: (((P23 (cdr a)) (P23 b)) (P23 (app (cdr a) b)))) (((P23 a) (P23 b)) (P23 (app a b)))] (((P23 (cdr a)) (P23 b)) (P23 (app (cdr a) b))) (P23 a) (P23 b)) (P23 (app a b))] (((P23 (cdr a)) (P23 b)) (P23 (app (cdr a) b))) (car a)=23 (P23 (cdr a)) (P23 b)) (P23 (cons (car a) (app (cdr a) b)))] (P23 (app (cdr a) b))) (car a)=23 (P23 (cdr a)) (P23 b)) (P23 (cons (car a) (app (cdr a) b)))] (P23 (app (cdr a) b))) (car a)=23 (P23 (cdr a)) (P23 b)) (P23 (cons 23 (app (cdr a) b)))] (Proof continued on next page.) x

{The following formula is exactly the same as the one at the bottom of the preceding page.} (P23 (app (cdr a) b))) (car a)=23 (P23 (cdr a)) (P23 b)) (P23 (cons 23 (app (cdr a) b)))] T (P23 (app (cdr a) b))) (car a)=23 (P23 (cdr a)) (P23 b)) (P23 (app (cdr a) b))] xi

Familiar Definitions (defun app (x y) (if (endp x) y (cons (car x) (app (cdr x) y)))) (defun tp (x) (if (endp x) (equal x nil) (tp (cdr x)))) ; Called true-listp in the notes. (defun mem (e x) (if (endp x) nil (if (equal e (car x)) t (mem e (cdr x))))) xii