CS 242, Section 002 Sonoma State University Spring, 2026
 
Discrete Structures for Computer Science
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College

Notes:


Assignment 2 (Predicates, Quantifiers, and Rules of Inference)

  1. Using Propositions and Laws of Propositional Logic:
    Note: (This problem is motivated by a sign on a stairway door in a hotel hallway, in the Washington, D.C. area.)
    The following six English statements are to be considered as propositions and applying to a given person on an upper-story floor in a hotel at a specified time:

    Next consider the following compound propositions (CPs), again considered as applying to a given person on an upper-story floor in a hotel at a specified time:

    Based on these propositions in English, answer the following questions.

    1. Translate each of the compound propositions (i.e., CP1, . . . CP6) from English into formal statements with the letters P, Q, R, S, and/or T and the logical operations ¬, ∨, ∧, and →, and using parentheses as needed. (Hint: CP1 translates simply to ¬P.)

    2. Form the expression CP4 ∧CP5 ∧ CP6, and use the Laws of Propositional logic from (in Section 1.5) to show that if there is a fire in the hotel, then the person cannot exit using the elevator.

      Note: For this argument, you must proceed step by step, following the same format utilized in the Participation Activities for Section 1.5.

    3. Extending the approach of part b, form the overall expression indicating all compound propositions are true.

      CP1 ∧ CP2 ∧ CP3 ∧ CP4 ∧ CP5 ∧ CP6

      and apply the Laws of Propositional Logic (Table 1.5.1 in the zyBook) step by step to find an expression equivalent to this extended proposition, but as simple as possible. (For example, can this expression be simplified to an expression with just one or two propositions?)

      Note: For this problem, you must proceed step by step, following the same format utilized in the Participation Activities for Section 1.5.

    4. Based on your answer to part c, what options are available to a person located on an upper floor of the hotel during a fire? Explain briefy.

    5. (Optional, rhetorical question, which you may or may not decide to answer—no points are associated with this answer) If a door is to remain closed at all times, what is the point of having the door?

  2. Performance of C and C++ Programs, Continued):
    Background/Motivation Problem 1 of Assignment 1 included these propositions for a given program A.

    1. Rewrite propositions P, Q, R, and s, as predicates, based on a variable x, with domain ranging over all programs.

    2. Now consider the following following functions

      • TC(x) the time it takes for program x to run as a C program
      • TP(x) the time it takes for program x to run as a C++ program
      • TC(x) the amount of member required for program x to run as a C progMam
      • MP(x) the amount of memory required for program x to run as a C++ program

      With these predicates and functions defined, express the following statements as compound predicates.

      1. If x is a C program, then it can be compiled and run both as a C and a C++ program.
      2. If x is a C program then its run time as a C++ program will be no more than its run time as a C program.
      3. If x is a program that can be run as either a C or C++ program, and if it requires more memory to run as a C program than a C++ program, then it cannot be a truly valid C program.
  3. Stating Propositions with Quantifiers: The Intermediate Value Theorem:
    Suppose y = f(x) is a continuous function on the interval [a, b], where f(x), a and b are defined globally, so do not need to be defined or bound within a predicate.

    Write a predicate with parameters/variables c and d that states the Intermediate Value Theorem:
    If a ≤ c < d ≤ b and if f(c) and f(d) have opposite signs (e.g., f(c) > 0 and f(d) < 0, or f(c) < 0 and f(d) > 0), then there is a value w between c and d where f(w) = 0.


created October 25, 2025
revised October-November, 2025
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.