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

Lecture-1 MCA

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

Lecture-1 MCA

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

Lecture-1 and 2

Introduction to FoL (Lecture-1)


• " FoL aka Discrete Mathematics " is not the name of a branch of
mathematics, like number theory, algebra, calculus, etc. Rather, it's a
description of a set of branches of math that all have in common the
feature that they are "discrete" rather than "continuous".
• The members of this set include (certain aspects of):
– Logic and Boolean algebra
– Set theory
– Relations and Functions
– Sequences and Series (or "sums")
– Algorithms and Theory of Computation
– Number Theory
– Matrix Theory
– Induction and Recursion
– Counting and Discrete Probability
– Graph Theory (including trees)

2
Application of FoLT
• Concepts and notations from FoL are useful in
studying and describing objects and problems
in branches of computer science, such as
– computer algorithms
– programming languages
– cryptography
– automated theorem proving
– software development.
– AI

3
Unit-1: Foundations of Logic or
Mathematical Logic : Overview
Mathematical Logic is a tool for working with elaborate
compound statements. It includes:
• A formal language for expressing them.
• A concise notation for writing them.
• A methodology for objectively reasoning about their
truth or falsity.
• It is the foundation for expressing formal proofs in all
branches of mathematics.
Unit-1: Foundations of Logic: Overview

• Propositional logic:
– Basic definitions.
– Equivalence rules & derivations.
• Predicate logic
– Predicates.
– Quantified predicate expressions.
– Equivalences & derivations.
Topic #1 – Propositional Logic

Propositional Logic
Propositional Logic is the logic of compound
statements built from simpler statements
using so-called Boolean connectives.
Some applications in computer science: George Boole
(1815-1864)
• Design of digital electronic circuits.
• Expressing conditions in programs.
• Queries to databases & search engines.

Chrysippus of Soli
(ca. 281 B.C. – 205 B.C.)
Topic #1 – Propositional Logic

Definition of a Proposition

Definition: A proposition (denoted p, q, r, …) is simply:


• a statement (i.e., a declarative sentence[Not: imperative
or interrogative])
– with some definite meaning, (not vague or ambiguous)
• having a truth value that’s either true (T) or false (F)
– it is never both, neither, or somewhere “in between!”
• However, you might not know the actual truth value,
• and, the truth value might depend on the situation or context.
Topic #1 – Propositional Logic

Examples of Propositions
• “It is raining.” (In a given situation.)
• “Beijing is the capital of China.” • “1 + 2 = 3”

• “Who’s there?”
• (interrogative, question)
• “La la la la la.”
• (meaningless interjection)
• “Just do it!”
• (imperative, command)
• “Yeah, I sorta dunno, whatever...”
• (vague)
• “1 + 2”
• (expression with a non-true/false value)
Topic #1.0 – Propositional Logic: Operators

Operators / Connectives

An operator or connective combines one or


more operand expressions into a larger
expression. (E.g., “+” in numeric exprs.)
• Unary operators take 1 operand (e.g., −3); binary
operators take 2 operands (eg 3  4).
• Propositional or Boolean operators operate on
propositions (or their truth values) instead of on
numbers.
Topic #1.0 – Propositional Logic: Operators

Some Popular Boolean Operators

Formal Name Nickname Arity Symbol


Negation operator NOT Unary ¬
Conjunction operator AND Binary 
Disjunction operator OR Binary 
Exclusive-OR operator XOR Binary 
Implication operator IMPLIES Binary 
Biconditional operator IFF Binary ↔
Topic #1.0 – Propositional Logic: Operators

The Negation Operator


The unary negation operator “¬” (NOT)
transforms a prop. into its logical negation.
E.g. If p = “I have brown hair.”
then ¬p = “I do not have brown hair.”
The truth table for NOT:
p p
T :≡ True; F :≡ False
T F
“:≡” means “is defined as” F T
Operand Result
column column
Topic #1.0 – Propositional Logic: Operators

The Conjunction Operator


The binary conjunction operator “” (AND)
combines two propositions to form their
logical conjunction. ND
E.g. If p=“I will have salad for lunch.” and q=“I
will have steak for dinner.”,
then pq=“I will have salad for lunch and
I will have steak for dinner.”

Remember: “” points up like an “A”, and it means “ND”


Topic #1.0 – Propositional Logic: Operators

Conjunction Truth Table


• Note that a Operand columns
conjunction p q p q
p1  p2  …  pn
of n propositions F F F
will have 2n rows F T F
in its truth table. T F F
T T T
• Also: ¬ and  operations together are suffi-
cient to express any Boolean truth table!
Topic #1.0 – Propositional Logic: Operators

The Disjunction Operator


The binary disjunction operator “” (OR)
combines two propositions to form their
logical disjunction.
p=“My car has a bad engine.”
q=“My car has a bad carburetor.” 
pq=“Either my car has a bad engine, or
my car has a bad carburetor.”

Meaning is like “and/or” in English.


Topic #1.0 – Propositional Logic: Operators

Disjunction Truth Table

• Note that pq means


p q p q
that p is true, or q is
true, or both are true!
F F F
Note
F T T difference
• So, this operation is from AND
T F T
also called inclusive or,
because it includes the T T T
possibility that both p and q are true.
Topic #1.0 – Propositional Logic: Operators

Nested Propositional Expressions

• Use parentheses to group sub-expressions:


“I just saw my old friend, and either he’s
grown or I’ve shrunk.”
– = f  (g  s)
– (f  g)  s would mean something different
– f  g  s would be ambiguous
• By convention, “¬” takes precedence over
both “” and “”.
– ¬s  f means (¬s)  f , not ¬ (s  f)
Topic #1.0 – Propositional Logic: Operators

A Simple Exercise
Let p=“It rained last night”,
q=“The sprinklers came on last night,”
r=“The lawn was wet this morning.”
Translate each of the following into English:
¬p =
r  ¬p = “It didn’t rain last night.”
“The lawn was wet this morning, and
it didn’t rain last night.”
¬rpq=
“Either the lawn wasn’t wet this morning, or it
rained last night, or the sprinklers came on last
night.”
Topic #1.0 – Propositional Logic: Operators

The Exclusive Or Operator


The binary exclusive-or operator “” (XOR)
combines two propositions to form their
logical “exclusive or” (exjunction?).
p = “I will earn an A in this course,”
q = “I will drop this course,”
p  q = “I will either earn an A in this course, or I
will drop it (but not both!)”
Topic #1.0 – Propositional Logic: Operators

Exclusive-Or Truth Table

• Note that pq means


p q pq
that p is true, or q is
true, but not both!
F F F
F T T
• This operation is
T F T
called exclusive or,
because it excludes the T T F Note
difference
from OR.
possibility that both p and q are true.
Topic #1.0 – Propositional Logic: Operators

The Implication Operator


The implication p  q states that p implies q.
I.e., If p is true, then q is true; but if p is not true,
then q could be either true or false.
E.g., let p = “You study hard.”
q = “You will get a good grade.”
p  q = “If you study hard, then you will get a
good grade.” (else, it could go either way)
Topic #1.0 – Propositional Logic: Operators

Implication Truth Table


• p  q is false only when
p is true but q is not true. p q p q
• p  q does not say F F T
that p causes q! F T T The
only
• p  q does not require T F F False
case!
that p or q are ever true! T T T
• “(1=0)  pigs can fly”
Topic #1.0 – Propositional Logic: Operators

Examples of Implications

• “If this lecture ever ends, then the sun will


rise tomorrow.” True or False?
• “If Tuesday is a day of the week, then I am
a bird.” True or False?
• “If 1+1=6, then Bush is president.”
True or False?
• “If the moon is made of green cheese, then
I am richer than Bill Gates.” True or False?
Topic #1.0 – Propositional Logic: Operators

English Phrases Meaning p  q


• “p implies q” • “p only if q”
• “if p, then q” • “p is sufficient for q”
• “if p, q” • “q is necessary for p”
• “when p, q” • “q follows from p”
• “whenever p, q” • “q is implied by p”
• “q if p” We will see some equivalent
logic expressions later.
• “q when p”
• “q whenever p”
Topic #1.0 – Propositional Logic: Operators

Converse, Inverse, Contrapositive


Some terminology, for an implication p  q:
• Its converse is: q  p.
• Its inverse is: ¬p  ¬q.
• Its contrapositive: ¬q  ¬ p.
• One of these three has the same meaning
(same truth table) as p  q. Can you figure
out which?
Topic #1.0 – Propositional Logic: Operators

How do we know for sure?


Proving the equivalence of p  q and its
contrapositive using truth tables:

p q q p p q  q   p
F F T T T T
F T F T T T
T F T F F F
T T F F T T
Topic #1.0 – Propositional Logic: Operators

The biconditional operator


The biconditional p  q states that p is true if and
only if (IFF) q is true.
p = “Bush wins the 2004 election.”
q = “Bush will be president for all of 2005.”
p  q = “If, and only if, Bush wins the 2004 election,
Bush will be president for all of 2005.”
2005
2004 I’m still
here!
Topic #1.0 – Propositional Logic: Operators

Biconditional Truth Table


p q pq
• p  q means that p and q
have the same truth value. F F T
• Note this truth table is the F T F
exact opposite of ’s!
Thus, p  q means ¬(p  q)
T F F
• p  q does not imply T T T
that p and q are true, or that either of them
causes the other, or that they have a common
cause.
Topic #1.0 – Propositional Logic: Operators

Boolean Operations Summary

• We have seen 1 unary operator (out of the


4 possible) and 5 binary operators (out of
the 16 possible). Their truth tables are
p q  p p q p q pq p q pq
below.
F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T
Topic #1.0 – Propositional Logic: Operators

Some Alternative Notations

Name: not and or xor implies iff


Propositional logic:      
Boolean algebra: p pq + 
C/C++/Java (wordwise): ! && || != ==
Logic gates:
Eg:1

What is the value of the variable x after the statement if 2 + 2 = 4 then x := x + 1 if


x = 0 before this statement is encountered? (The symbol := stands for assignment.
The statement x := x + 1 means the assignment of the value of x + 1 to x.)
Ans:1

Solution: Because 2 + 2 = 4 is true, the assignment statement x := x


+ 1 is executed. Hence, x has the value 0 + 1 = 1 after this statement
is encountered.
What are the contrapositive, the converse, and the inverse of the conditional
statement “The home team wins whenever it is raining?”
Solution: Because “q whenever p” is one of the ways to express the conditional
statement p → q, the original statement can be rewritten as “If it is raining, then
the home team wins.”

Consequently, the contrapositive of this conditional statement is “If the home


team does not win, then it is not raining.”

The converse is “If the home team wins, then it is raining.”

The inverse is “If it is not raining, then the home team does not win.”

Only the contrapositive is equivalent to the original statement.


Eg:3
Precedence of Logical Operators
e.g:4
let a, c, and f represent “You can access the Internet from campus,”
“You are a computer science major,” and “You are a freshman,” respectively.
Noting that “only
if” is one way a conditional statement can be expressed, this sentence can be
represented as

You might also like