UP | HOME
../../

Background in Discrete Math and Logic

Table of Contents

Abstract: This article is a collection of notes on what students of Software Engineering (undergrad or grad) should know. It is assumed that a sophomore level course in Discrete Mathematics and Logic was taken. I am refraining from describing notations. As we use these ideas in our course, I will explain the notations. [New entries will be added as I discover what the students are unclear about.]

1 Sets, Bags, Tuples and Sequences

1.1 Sets

  1. Sets are collections of items.
  2. In math, a set can be a collection of dissimilar things such as a set of an orange, an elephant, a human, and a stone.
  3. In CS, our sets are (almost always) of values from a given type. E.g., a set of characters.
  4. In a set, there is no notion of duplication. A given item is or is not in a set. Some times, we may post the question: How many times does i appear in S? The answer can only be a 0 or 1.
  5. In a set, there is no notion of order. So, you can jumble up a set.
  6. Empty sets are highly useful.

1.2 Bags

  1. Bags are like sets, except there is a notion of duplication.
  2. The Q "How many times does i appear in a bag B? The answer can be a 0, 1 or higher.

1.3 Sequences

  1. Sequences are like bags, except there is a notion of order.
  2. So, there is a first, second, …, last item of a seq Q.
  3. The question "How many times does i appear in a seq Q? The answer can be a 0, 1 or higher.

1.4 Tuples

  1. Tuples are like sequences, but need not be of like values. They can be dissimilar. In CS, these also by the names of "records", structs, and "data members" (of a class).
  2. In our use, there is a first, second, …, last item of a tuple T.
  3. Equally frequently, instead of first, second, …, we may name the "fields" of a tuple T (like "data members" of a class).
  4. Tuples can be empty too!
  5. Tuples to seq conversion is "ok" only if all items were of the same type.
  6. Seq to tuples conversion is as expected.

2 Tables

  1. Tables are sets of tuples, all of a given length. Thus, we can visualize a table as columns of rows.

3 Functions and Relations

  1. A relation maps elements of its domain set into elements of its range set.
  2. When a relation is such that no element is mapped to more than one element in the range, it becomes function.

4 Propositions

  1. True and False are propositions.
  2. For other propositions, we often use letters. These are assigned a True or False value in an interpretation.
  3. A formula involves these things and the and (^) or (v) not (~) symbols also. A well-formed-formula (wff) is defined synatctically.

5 Predicates

  1. Ex: x > 1 is a predicate. It has one free variable, x. In the programming context, think of free variables as globally scoped variables.
  2. Predicates can involve for-all and there-exists quantifiers.

6 A implies B (A => B)

6.1 Propositions A, B: A => B

  1. A implies B is often written as A => B.
  2. By def, same as not A or B. Hence,
    1. A => A,
    2. (False => B) is true for arbitrary B.
    3. (True > B) only if B = True. It is false otherwise.
    4. WhatEver => True.

6.2 Predicates A, B: A => B

  1. In CS, it is highly useful to use attributes of size to A and B. Suppose we already know that A => B. Consider: The size of the set of values, #A, that make A true versus the size #B of the set of values that make B true. Is #A >= #B? Assume that both of these are finite numbers.

6.3 For-All/ There-Exists P(x)

  1. The domain X of x is/ ought-to-be clear from the context.
  2. for-all x: P(x) is the and-ing of P(a) for all a in X.

7 Weaker/Stronger Predicates

  1. If A => B we say A is stronger than B. Assuming A ! = B. We can reverse: B is weaker than A.
  2. Simple example on predicates: x > 7 implies x > 1.
  3. Consider: P implies Q (also written as P => Q)
  4. We say that P is stronger than Q. Alt: Q is weaker than P.
    1. P and Q, in general, have free variables, x, y, z, … Consider a particular assignment A of values for each of x, y, z that make P come out True. A will also make Q True.
  5. In the context of programming, we can refer to this A as a "state".
  6. Let C(Q) be the collection of such assignment of values that make Q come out as True.
    1. Let C(P) be the collection of such values that make P come out as True.
    2. C(P) is a subset of C(Q)
    3. If C(P) = C(Q), P is equivalent to Q (also written as P ⇔ Q, or P ≡ Q).

8 End


Copyright © 2016 • www.wright.edu/~pmateti 2016-01-11