Logic

Logic is the study of principles and methods that distinguish between a valid and invalid statement

It can also be referred as proposition

Logic is the basis of mathematical reasoning.

It will help you develop strong skills that is needed to make programming logic, algorithms and it will also be helpful in other fields of computer Science.

To understand mathematics one must understand to make a mathematical argument that is proof or logic

Statement:

“A statement is a declarative sentence that is either true or false but not both”

If a proposition is true we can say that it has a truth value of ‘true’ .
If a proposition is false its truth value is false.

For Example:

1. It is Friday today
2. Islamabad is capital of Pakistan
3. 3 + 2 = 6
4. 1 + 2 = 4

In above examples truth value of statement 1 and 2 is true . In the example 3 and 4 the truth value of statements is false

Compound Statement:

Simple statement could be used to build a compound statement

For Example:

1. “6 + 4 = 10” and “Multan is a city in Pakistan”
2. “The grass is green” or “It is sunny today”
3. “English is not difficult for me”

Logical Connectives:

AND, OR, NOT are called LOGICAL CONNECTIVES

Prepositional Variables:

Variables that represent prepositions such as ‘p , q , r , s …..’ are prepositional or statement variables. Statements are symbolically represented by these letters.

The truth value of a statement is true ,denoted by T , if it is a true statement.

The truth value of a statement is false, denoted by f , if it is a false statement .

= Islamabad is capital of Pakistan

q = “15 is divisible by 5”

Truth Table :

A convenient method for analyzing a compound statement is to make a truth table.A truth table specifies a truth value of a compound preposition.

Negation:

If p is a statement variable, then negation of p, “not p”, is denoted as “~p”

It has opposite truth value from p i.e.,

if p is true, ~p is false; if p is false, ~p is true.

Example 1:

Find the negation of the proposition
“Ayesha’s PC runs windows 10.”

Solution:     “Ayesha’s PC does not run Windows 10.”

Example 2:

Find the negation of the proposition
“Nabiha’s phone has at least 18 GB of memory.”

Solution:    “Nabiha’s phone does not have at least 18 GB of memory.”

TRUTH TABLE FOR  ~ p :

Conjunction:

If p and q are statements, then the conjunction of p and q is “p and q”, denoted as “p Λ q”.

It is true when, and only when, both p and q are true. If either p or q s false, or if both are false, pΛq is false.

Example 3:

Find the conjunction of the propositions p and q where p is the proposition“Multan is a city of Pakistan.”and q is the proposition “Ali’s PC run faster than 1 GHz.”

Solution: “Multan is a city of Pakistan and Ali’s PC run faster than 1 GHz. .”

Truth table for p ∧ q: DISJUNCTION:

If p & q are statements, then the dis-junction of p and  q is “p or q”, denoted as“p ∨  q”.It is true when at least one of p or q is true and is false only when both p and q are false.

Example 3:

Find the disjunction of the propositions p and q where p is the proposition“Multan is a city of Pakistan.”and q is the proposition “Ali’s PC run faster than 1 GHz.”

Solution: “Multan is a city of Pakistan, or Ali’s PC run faster than 1 GHz. .”

TRUTH TABLE FOR p ∨ q: 