Fundamentals of Computer Science - Week 1 (Essential reading) - Part 1 out of 2

Rosen, K.H. Discrete mathematics and its applications (New York: McGraw-Hill, 2012) 7th edition, Chapter 1.1-1.2, pp.1-22.

Proposition: a proposition is a declarative sentence (that is, a sentence that declares a fact) that is either true or false.

We use letters to denote propositional variables (or statement variables), that is, variables that represent propositions. Conventional letters used for prositional ariables are p, q, r, s. Truth is denoted by T whereas false is denoted by F.

Operators:

The "not" operator stands for "is not the case".
The conditional statement (p -> q) stands for "if..then" and it asserts that q is true on the condition that p holds. A useful way to understand the truth value of a conditional statement is to think of an obligation or a contract.


Converse, contrapositive, and inverse

For p->q,

Converse: q->p
Contrapositive:  !q -> !p
Inverse: !p -> !q

Logic and Bit Operations

Computers represent information using bits. A bit is a symbol with two possible values, 0 and 1. Word meaning comes from "b"inary dig"it". A bot cam ne ised tp [represent a truth value. There are only two truth values, true and false. 1 is for TRUE and 0 is for FALSE.

A variable is called a Boolean variable if its value is either true or false.

Computer "bit" operations correspond to the logical connectives.

TABLE FOR THE BIT OPERATORS OR, AND, AND XOR

| x | y | x or y | x and y | x xor y |
|    |    |           |              |              |
| 0 | 0 |    0     |      0      |      0      |
| 0 | 1 |    1     |      0      |      1      |
| 1 | 0 |    1     |      0      |      1      |
| 1 | 1 |    1     |      1      |      0      |
__________________________

Note: A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string.

Find the bitwise OR, bitwise AND, and bitwise XOR of the strings:

01 1011 0110
11 0001 1101

11 1011 1111 - OR
01 0001 0100 - AND
10 1010 1011 - XOR

Comments

Popular posts from this blog

syllabus: Algorithms and Data Structures 1 [CM1035]

syllabus: Fundamentals of Computer Science [CM1025]

Introduction to Programming - Week 1 and 2 Summary