0% found this document useful (0 votes)
8 views

MMW and COMPUTER PROGRAMMING

mmw

Uploaded by

darienvalmeo2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

MMW and COMPUTER PROGRAMMING

mmw

Uploaded by

darienvalmeo2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Logic

Logic
Logic is the study of reasoning and argumentation. It involves the
principles and methods used to distinguish valid from invalid reasoning,
focusing on how conclusions are drawn from premises.
Logic is regarded as one of the oldest intellectual disciplines in the
history of humanity. It was the Greek philosopher Aristotle who
pioneered logical reasoning. Throughout centuries, logic has immensely
influenced other fields such as philosophy, mathematics, science,
engineering, business, and law, to name a few.
Mathematical Logic
Basically, mathematical logic is a subfield of mathematics exploring the
applications of formal logic to mathematics. Critical thinking or logical
thinking is the process in which one uses logic and reasoning consistently to
conclude, which is an important foundational skill of Mathematics. It is used as
a process to evaluate and separate truth from falsehood, reasonable from
unreasonable beliefs.
Propositional
Logic
Propositions
• A proposition is a statement that has a truth value.
• Two possible truth values associated with propositions:
True (T or 1)
False (F or 0)

A proposition is a complete declarative sentence that is either


true (T) or false (F), but not both.
Determine which of the following is a proposition and determine its truth value.

a. Manila is the capital of the Philippines. a. Proposition- T


b. Today is Sunday. b. Proposition- depends on the case
c. Twice seven increase by five is twenty- five. c. Proposition- F
d. I am feeling good today. d. Not proposition- subjective
e. Listen to me. e. Not proposition- imperative
f. Is it the right thing to do? f. Not proposition- interrogative
g. x + 1 = 2; x = 5 g. Proposition- F
h. x+y=z h. Not Proposition- unknown values
i. Ouch!
i. Not Proposition- exclamatory
Propositional Logic
A proposition is denoted by small letters such as p, q and r.

A propositional connective or operator is an operation that


combines two propositions to yield a new one.

Propositions built up using propositional connectives are called


propositional logic or compound/ conjoined propositions.

The truth value of such a new statement is then completely


determined by the truth values of the given statements.
Logical Connectives/ Logical Operators
Example
Propositional Symbolic
Connective Symbol/Term Read as p: 2 is even.
Logic Form
q: 2 is prime.
~ curl or tilde ~p ~𝐩: 2 is odd.
Negation not not p
¬ dash with a tail ¬p ~𝐪: 2 is not prime.
∧ wedge (logical p ∧ q:
Conjunction and/but p∧q p and q
and) 2 is even and 2 is prime.
p⋁q:
Disjunction or ∨ vee (logical or) p∨q p or q
2 is even or 2 is prime.

if p, then q
p implies q
𝐩 → 𝐪:
Conditional/ q only if p
if..., then → right arrow p→q If 2 is even, then 2 is prime.
Implication q if p
2 is prime if 2 is even.
q whenever p
q is necessary for p

p if and only if q
double-headed 𝐩 𝐪:
Biconditional if and only if p q p implies q, and q
arrow 2 is even if and only if 2 is prime.
implies p
Translate the following propositions into symbols.
p : Today is a holiday. ~ (not) ⋀ (and)
q : We have no classes today. ⋁ (or) → (implies)
r : We need to review our lessons. (if and only if)

1. Today is not a holiday. 1. ~𝑝

2. We have classes today and we need to review our lessons. 2. ~𝑞 ∧ 𝑟


3. If today is a holiday, then we do not need to review our lessons. 3. 𝑝 ⟶ ~𝑟
4. Today is a holiday if and only if we have no classes today. 4. 𝑝 ⟷ 𝑞
5. Either we have no classes today, or both today is a not a holiday and 5. 𝑞 ∨ (~𝑝 ∧ 𝑟)
we need to review our lessons.
6. ~𝑝 ⟶ ~𝑞 ∧ 𝑟
6. We have classes today and we need to review our lessons, if today is
not a holiday. 7. ~𝑝 ⟷ ~𝑞 ∨ 𝑟
7. Today is not a holiday if and only if either we have classes today or we 8. ~ (𝑝 ∨ 𝑞)
need to review our lessons.
8. Neither today is a holiday nor we have no classes today.
Write in statement.

p: 5 > 3
q: 5 is odd.
r: 5 is prime.
s: 5 is not divisible by 2.

1. q → s If 5 is odd, then 5 is not divisible by 2.


2. ~p⋁q 5 ≤ 3 or 5 is odd.
3. ~q⋀r 5 is even and 5 is prime.
4. q → (r ⋀ ~s)
If 5 is odd, then 5 is prime and 5 is divisible by 2.
5. (p ⋀ ~q) ~s
5 > 3 and 5 is even, if and only if 5 is divisible by 2.
Truth Values
of Propositions
with Operators
Negation
Ex.1 5 + 7 = 12 True
5 + 7 ≠ 12 False
Ex. 2 Three is an irrational number. False
Three is a rational number. True

In negation, a true proposition will become false, and a false


proposition will become true.
Conjunction
Given:
p: 2 is prime. q: 2 is even. r: 2 > 3

p ∧ q: 2 is prime and 2 is even. T∧T=T


p ∧ r: 2 is prime but 2 > 3. T∧F=F
~q ∧ ~ r: 2 is odd and 2 ≤ 3. F∧T=F
~p ∧ ~ q: 2 is composite but 2 is odd. F∧F=F

The proposition p ∧ q is true when both p and q are true.


Otherwise, it is false.
Conjunction
Some other words to denote conjunction:
Moreover
Furthermore
, (comma)
: (colon)
However
Also
Yet
Nevertheless
Still
Although
Disjunction
Given:
p: 2 is prime. q: 2 is even. r: 2 > 3

p V q: 2 is prime or 2 is even. TVT=T


p V r: 2 is prime or 2 > 3. TVF=T
~q V ~ r: 2 is odd or 2 ≤ 3. FVT=T
~p V ~ q: 2 is composite or 2 is odd. FVF=F

The proposition p⋁ q is true if either p or q is true, or both are true.


It is only false if both propositions are false.
Disjunction
Other word for disjunction:
Unless
Compound Connectives
In Words Symbols
Both p or q, and r (p ⋁ q) ⋀ r
p or both q and r p ⋁ (q ⋀ r)
Either p and q, or r (p ⋀ q) ⋁ r
p and either q or r p ⋀ (q ⋁ r )
Neither p nor q ~ (p ⋁ q)
Compound Connectives
Given:
p: 2 is prime. q: 2 is even. r: 2 > 3

(p ⋁ q) ⋀ rr Both 2 is prime or even, and 2 > 3.


p ⋁ (q ⋀ r) Either 2 is prime, or both 2 is even and 2 > 3.
(p ⋀ q) ⋁ r Either 2 is prime and even, or 2 > 3.
p ⋀ (q ⋁ r ) 2 is prime, and either 2 is even or 2 > 3.
~ (p ⋁ q) 2 is neither prime nor even.
Conditional Propositions (Logical Implication)
p : Today is Monday.
q : We have classes today.

𝒑→𝒒∶ Proposition p is the hypothesis, q is the conclusion.

p implies q Today is Monday implies that we have classes today.


If p, then q If today is Monday, then we have classes today.
q only if p We have classes today only if it is Monday.
q if p We have classes today if today is Monday.
q whenever p We have classes today whenever it is Monday.
Conditional Propositions (Logical Implication)
Given:
p: You ace the exam. q: You will get a reward.

p → q: If you ace the exam, you will get a reward. T→T=T


p → ~ q: If you ace the exam, you will not get a reward. T→F=F
~p → q: If you do not ace the exam, you will get a reward. F→T=T
~p → ~ q: If you do not ace the exam, you will not get a reward. F→F=T

The proposition 𝒑 → 𝒒 is only false if the hypothesis is true but the


conclusion is false.
Biconditional Propositions (Double Equivalent)
Given:
p: 36 is divisible by 6. q: 36 is divisible by 2 and 3.

p q: 36 is divisible by 6 if and only if it is divisible by 2 and 3. T T=T

p ~ q: 36 is divisible by 6 if and only if it is not divisible by 2 and 3. T F=F


~p q: 36 is not divisible by 6 if and only if it is divisible by 2 and 3. F T=F
~p ~ q: 36 is not divisible by 6 if and only if it is not divisible by 2 and 3. F F=T

The biconditional proposition of propositions p and q is true if both propositions


are true, or both are false. Otherwise, the proposition is false.
Write in statement and determine the truth value:

p: 5>3
q: 5 is odd.
r: 5 is prime.
s: 5 is not divisible by 2.

1. q→s If 5 is odd, then 5 is not divisible by 2. T→T=T


2. ~p⋁q 5 ≤ 3 or 5 is odd. F⋁T = T
3. ~q⋀r 5 is even and 5 is prime. F⋀T = F
4. q → (r ⋀ ~s) If 5 is odd, then 5 is prime and 5 is divisible by 2. T → (T ⋀ F) = F
5. (p ⋀ ~q) ~s 5 > 3 and 5 is even, if and only if 5 is divisible by 2. (T ⋀ F) F=T
Logical Implications
In an implication of the form 𝑝 → 𝑞 , the proposition p is called the
hypothesis (antecedent) and the proposition q is called the conclusion
(consequence). From this form, we can have another statements which are
the converse, inverse and contrapositive of 𝑝 → 𝑞.
• Converse: If 𝑝 → 𝑞, then its converse is 𝑞 → 𝑝.
• Inverse: If 𝑝 → 𝑞, then its inverse is ∼ 𝑝 →∼ 𝑞.
• Contrapositive: If 𝑝 → 𝑞, then its contrapositive is ∼ 𝑞 → ∼ 𝑝.
Logical Implications
Examples (Using if p, then q):
p: We have exams today.
q: I need to review.
𝑝 → 𝑞: If we have exams today, then I need to review.
Converse:
𝑞 → 𝑝: If I need to review, then we have exams today.
Inverse:
∼ 𝑝 →∼ 𝑞: If we do not have exams today, then I do not need to review.
Contrapositive:
∼ 𝑞 → ∼ 𝑝: If I do not need to review, then we do not have exams today.
Logical Implications
Examples (using if p, then q):
p: A number is even.
q: A number is divisible by 2.
𝑝 → 𝑞: If a number is even, then it is divisible by 2.
Converse:
𝑞 → 𝑝: If a number is divisible by 2, then it is even.
Inverse:
∼ 𝑝 →∼ 𝑞: If a number is odd, then it is not divisible by 2.
Contrapositive:
∼ 𝑞 → ∼ 𝑝: If a number is not divisible by 2, then it is odd.
Logically Equivalent Propositions
If 3 is odd, then 3 is not divisible by two. (implication)
If 3 is divisible by two, then 3 is even. (contrapositive)

3 is prime, if 3 is odd. (implication)


3 is even, if 3 is not prime. (contrapositive)
If 3 is not prime, then 3 is even.
Logically Equivalent Propositions
If x is divisible by 6, then it is divisible by 3 and 2.
If x is not divisible by 3 and 2, then it is not divisible by 6.

A set has 32 subsets, if it has 5 elements.


A set does not have 5 elements, if it does not have 32 subsets.
If a set does not have 32 subsets, then it does not have 5 elements.

You might also like