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:**

- It is Friday today
- Islamabad is capital of Pakistan
- 3 + 2 = 6
- 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:**

- “6 + 4 = 10”
**and**“Multan is a city in Pakistan” - “The grass is green”
**or**“It is sunny today” - “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 .

** p **= 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

is a statement variable, then negation ofpp,, is denoted as“not p”“~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:

Ifandpare statements, then the conjunction ofqandpisqdenoted as“p and q”,“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&pare statements, then the dis-junction ofqandpisqdenoted as“p or 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.“p ∨ q”.

**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:**