SlideShare une entreprise Scribd logo
1  sur  21
The Fundamentals of Logic
Module #1 - Logic
Module #1: Foundations of Logic
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.
Module #1 - 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:
Design of digital electronic circuits.
Expressing conditions in programs.
Queries to databases & search engines.
Topic #1 – Propositional Logic
George Boole
(1815-1864)
Chrysippus of Soli
(ca. 281 B.C. – 205 B.C.)
Module #1 - Logic
Definition of a Proposition
Definition: A proposition (denoted p, q, r, …) is simply:
a statement (i.e., a declarative sentence)
– 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.
Later, we will study probability theory, in which we assign degrees of
certainty (“between” T and F) to propositions.
– But for now: think True/False only!
Topic #1 – Propositional Logic
Module #1 - Logic
Examples of Propositions
“It is raining.” (In a given situation.)
“Beijing is the capital of China.” • “1 + 2 = 3”
But, the following are NOT propositions:
“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 – Propositional Logic
Module #1 - Logic
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
Module #1 - Logic
Some Popular Boolean Operators
Formal NameFormal Name NicknameNickname ArityArity SymbolSymbol
Negation operatorNegation operator NOTNOT UnaryUnary ¬¬
Conjunction operatorConjunction operator ANDAND BinaryBinary ∧∧
Disjunction operatorDisjunction operator OROR BinaryBinary ∨∨
Exclusive-OR operatorExclusive-OR operator XORXOR BinaryBinary ⊕⊕
Implication operatorImplication operator IMPLIESIMPLIES BinaryBinary →→
Biconditional operatorBiconditional operator IFFIFF BinaryBinary ↔↔
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
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 F
F T
T :≡ True; F :≡ False
“:≡” means “is defined as”
Operand
column
Result
column
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
The Conjunction Operator
The binary conjunction operator “∧” (AND)
combines two propositions to form their
logical conjunction.
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 “” points up like an “A”, and it means “∧∧NDND””
∧∧NDND
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
Conjunction Truth Table
Note that a
conjunction
p1 ∧ p2∧ … ∧ pn
of n propositions
will have 2n
rows
in its truth table.
Also: ¬ and ∧ operations together are suffi-
cient to express any Boolean truth table!
p q p∧q
F F F
F T F
T F F
T T T
Operand columns
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
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.” After the downward-
pointing “axe” of “∨∨””
splits the wood, yousplits the wood, you
can take 1 piece OR thecan take 1 piece OR the
other, or both.other, or both.
∨∨
Topic #1.0 – Propositional Logic: Operators
Meaning is like “and/or” in English.
Module #1 - Logic
Disjunction Truth Table
Note that p∨q means
that p is true, or q is
true, or both are true!
So, this operation is
also called inclusive or,
because it includes the
possibility that both p and q are true.
“¬” and “∨” together are also universal.
p q p∨ q
F F F
F T T
T F T
T T T
Note
difference
from AND
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
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
Module #1 - Logic
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 =
¬ r ∨ p ∨ q =
“It didn’t rain last night.”
“The lawn was wet this morning, and
it didn’t rain last night.”
“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
Module #1 - Logic
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
Module #1 - Logic
Exclusive-Or Truth Table
Note that p⊕q means
that p is true, or q is
true, but not both!
This operation is
called exclusive or,
because it excludes the
possibility that both p and q are true.
“¬” and “⊕” together are not universal.
p q p⊕ q
F F F
F T T
T F T
T T F Note
difference
from OR.
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
Natural Language is Ambiguous
Note that English “or” can be ambiguous
regarding the “both” case!
“Pat is a singer or
Pat is a writer.” -
“Pat is a man or
Pat is a woman.” -
Need context to disambiguate the meaning!
For this class, assume “or” means inclusive.
p q p "or" q
F F F
F T T
T F T
T T ?
∨
⊕
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
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
antecedent consequent
Module #1 - Logic
Implication Truth Table
p → q is false only when
p is true but q is not true.
p → q does not say
that p causes q!
p → q does not require
that p or q are ever true!
E.g. “(1=0) → pigs can fly” is TRUE!
p q p→q
F F T
F T T
T F F
T T T
The
only
False
case!
Topic #1.0 – Propositional Logic: Operators
Module #1 - Logic
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 penguin.” 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
Module #1 - Logic
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 below.
p q ¬p p∧q p∨q p⊕q p→q p↔q
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

Contenu connexe

Tendances

Cs6503 theory of computation book notes
Cs6503 theory of computation book notesCs6503 theory of computation book notes
Cs6503 theory of computation book notesappasami
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture NotesFellowBuddy.com
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theoryNYversity
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologDataminingTools Inc
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that WordKevlin Henney
 
Statistical machine translation
Statistical machine translationStatistical machine translation
Statistical machine translationasimuop
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computationprasadmvreddy
 
Latent Class Transliteration based on Source Language Origin
Latent Class Transliteration based on Source Language OriginLatent Class Transliteration based on Source Language Origin
Latent Class Transliteration based on Source Language OriginRakuten Group, Inc.
 
Propositional logic by shawan
Propositional logic by shawanPropositional logic by shawan
Propositional logic by shawanTouhidul Shawan
 
Latent Semantic Transliteration using Dirichlet Mixture
Latent Semantic Transliteration using Dirichlet MixtureLatent Semantic Transliteration using Dirichlet Mixture
Latent Semantic Transliteration using Dirichlet MixtureRakuten Group, Inc.
 
Translating English to Propositional Logic
Translating English to Propositional LogicTranslating English to Propositional Logic
Translating English to Propositional LogicJanet Stemwedel
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculusEdward Blurock
 

Tendances (20)

Cs6503 theory of computation book notes
Cs6503 theory of computation book notesCs6503 theory of computation book notes
Cs6503 theory of computation book notes
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
App a
App aApp a
App a
 
Logic
LogicLogic
Logic
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
 
Prolog
PrologProlog
Prolog
 
Fafl notes [2010] (sjbit)
Fafl notes [2010] (sjbit)Fafl notes [2010] (sjbit)
Fafl notes [2010] (sjbit)
 
PROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In PrologPROLOG: Cuts And Negation In Prolog
PROLOG: Cuts And Negation In Prolog
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that Word
 
Statistical machine translation
Statistical machine translationStatistical machine translation
Statistical machine translation
 
True but Unprovable
True but UnprovableTrue but Unprovable
True but Unprovable
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
FP 4 OOP FTW!
FP 4 OOP FTW!FP 4 OOP FTW!
FP 4 OOP FTW!
 
Latent Class Transliteration based on Source Language Origin
Latent Class Transliteration based on Source Language OriginLatent Class Transliteration based on Source Language Origin
Latent Class Transliteration based on Source Language Origin
 
Nlp
NlpNlp
Nlp
 
Propositional logic by shawan
Propositional logic by shawanPropositional logic by shawan
Propositional logic by shawan
 
Latent Semantic Transliteration using Dirichlet Mixture
Latent Semantic Transliteration using Dirichlet MixtureLatent Semantic Transliteration using Dirichlet Mixture
Latent Semantic Transliteration using Dirichlet Mixture
 
Translating English to Propositional Logic
Translating English to Propositional LogicTranslating English to Propositional Logic
Translating English to Propositional Logic
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
 

Similaire à Logic

Nsu module 01-logic-final
Nsu module 01-logic-finalNsu module 01-logic-final
Nsu module 01-logic-finalSOURAV
 
Mathematical Logic
Mathematical LogicMathematical Logic
Mathematical LogicJoey Valdriz
 
Logic - mathematics in the modern world.
Logic - mathematics in the modern world.Logic - mathematics in the modern world.
Logic - mathematics in the modern world.gregtzy01
 
Propositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxPropositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxShaukatAliChaudhry1
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)SHUBHAM KUMAR GUPTA
 
S2 1
S2 1S2 1
S2 1IIUM
 
Prolog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfProlog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfCS With Logic
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problemsJyotsna Suryadevara
 
Logic in Computer Science Unit 2 (1).pptx
Logic in Computer Science Unit 2 (1).pptxLogic in Computer Science Unit 2 (1).pptx
Logic in Computer Science Unit 2 (1).pptxPriyalMayurManvar
 
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...Ashish Duggal
 
Discrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.pptDiscrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.pptNandiniSR2
 

Similaire à Logic (20)

4535092.ppt
4535092.ppt4535092.ppt
4535092.ppt
 
Nsu module 01-logic-final
Nsu module 01-logic-finalNsu module 01-logic-final
Nsu module 01-logic-final
 
Mathematical Logic
Mathematical LogicMathematical Logic
Mathematical Logic
 
Logic - mathematics in the modern world.
Logic - mathematics in the modern world.Logic - mathematics in the modern world.
Logic - mathematics in the modern world.
 
Dm1
Dm1Dm1
Dm1
 
Propositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptxPropositional logic in Discretes tructures.pptx
Propositional logic in Discretes tructures.pptx
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)
 
Lecture 01.ppt
Lecture 01.pptLecture 01.ppt
Lecture 01.ppt
 
S2 1
S2 1S2 1
S2 1
 
Prolog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfProlog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdf
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Logic in Computer Science Unit 2 (1).pptx
Logic in Computer Science Unit 2 (1).pptxLogic in Computer Science Unit 2 (1).pptx
Logic in Computer Science Unit 2 (1).pptx
 
CSE680-17NP-Complete.pptx
CSE680-17NP-Complete.pptxCSE680-17NP-Complete.pptx
CSE680-17NP-Complete.pptx
 
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
 
Discrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.pptDiscrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.ppt
 
continuity of module 2.pptx
continuity of module 2.pptxcontinuity of module 2.pptx
continuity of module 2.pptx
 
dma_ppt.pdf
dma_ppt.pdfdma_ppt.pdf
dma_ppt.pdf
 
ICS1019.pdf
ICS1019.pdfICS1019.pdf
ICS1019.pdf
 
Mp neuron
Mp neuronMp neuron
Mp neuron
 
Pnp
PnpPnp
Pnp
 

Dernier

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 

Dernier (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 

Logic

  • 2. Module #1 - Logic Module #1: Foundations of Logic 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.
  • 3. Module #1 - 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: Design of digital electronic circuits. Expressing conditions in programs. Queries to databases & search engines. Topic #1 – Propositional Logic George Boole (1815-1864) Chrysippus of Soli (ca. 281 B.C. – 205 B.C.)
  • 4. Module #1 - Logic Definition of a Proposition Definition: A proposition (denoted p, q, r, …) is simply: a statement (i.e., a declarative sentence) – 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. Later, we will study probability theory, in which we assign degrees of certainty (“between” T and F) to propositions. – But for now: think True/False only! Topic #1 – Propositional Logic
  • 5. Module #1 - Logic Examples of Propositions “It is raining.” (In a given situation.) “Beijing is the capital of China.” • “1 + 2 = 3” But, the following are NOT propositions: “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 – Propositional Logic
  • 6. Module #1 - Logic 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
  • 7. Module #1 - Logic Some Popular Boolean Operators Formal NameFormal Name NicknameNickname ArityArity SymbolSymbol Negation operatorNegation operator NOTNOT UnaryUnary ¬¬ Conjunction operatorConjunction operator ANDAND BinaryBinary ∧∧ Disjunction operatorDisjunction operator OROR BinaryBinary ∨∨ Exclusive-OR operatorExclusive-OR operator XORXOR BinaryBinary ⊕⊕ Implication operatorImplication operator IMPLIESIMPLIES BinaryBinary →→ Biconditional operatorBiconditional operator IFFIFF BinaryBinary ↔↔ Topic #1.0 – Propositional Logic: Operators
  • 8. Module #1 - Logic 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 F F T T :≡ True; F :≡ False “:≡” means “is defined as” Operand column Result column Topic #1.0 – Propositional Logic: Operators
  • 9. Module #1 - Logic The Conjunction Operator The binary conjunction operator “∧” (AND) combines two propositions to form their logical conjunction. 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 “” points up like an “A”, and it means “∧∧NDND”” ∧∧NDND Topic #1.0 – Propositional Logic: Operators
  • 10. Module #1 - Logic Conjunction Truth Table Note that a conjunction p1 ∧ p2∧ … ∧ pn of n propositions will have 2n rows in its truth table. Also: ¬ and ∧ operations together are suffi- cient to express any Boolean truth table! p q p∧q F F F F T F T F F T T T Operand columns Topic #1.0 – Propositional Logic: Operators
  • 11. Module #1 - Logic 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.” After the downward- pointing “axe” of “∨∨”” splits the wood, yousplits the wood, you can take 1 piece OR thecan take 1 piece OR the other, or both.other, or both. ∨∨ Topic #1.0 – Propositional Logic: Operators Meaning is like “and/or” in English.
  • 12. Module #1 - Logic Disjunction Truth Table Note that p∨q means that p is true, or q is true, or both are true! So, this operation is also called inclusive or, because it includes the possibility that both p and q are true. “¬” and “∨” together are also universal. p q p∨ q F F F F T T T F T T T T Note difference from AND Topic #1.0 – Propositional Logic: Operators
  • 13. Module #1 - Logic 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
  • 14. Module #1 - Logic 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 = ¬ r ∨ p ∨ q = “It didn’t rain last night.” “The lawn was wet this morning, and it didn’t rain last night.” “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
  • 15. Module #1 - Logic 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
  • 16. Module #1 - Logic Exclusive-Or Truth Table Note that p⊕q means that p is true, or q is true, but not both! This operation is called exclusive or, because it excludes the possibility that both p and q are true. “¬” and “⊕” together are not universal. p q p⊕ q F F F F T T T F T T T F Note difference from OR. Topic #1.0 – Propositional Logic: Operators
  • 17. Module #1 - Logic Natural Language is Ambiguous Note that English “or” can be ambiguous regarding the “both” case! “Pat is a singer or Pat is a writer.” - “Pat is a man or Pat is a woman.” - Need context to disambiguate the meaning! For this class, assume “or” means inclusive. p q p "or" q F F F F T T T F T T T ? ∨ ⊕ Topic #1.0 – Propositional Logic: Operators
  • 18. Module #1 - Logic 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 antecedent consequent
  • 19. Module #1 - Logic Implication Truth Table p → q is false only when p is true but q is not true. p → q does not say that p causes q! p → q does not require that p or q are ever true! E.g. “(1=0) → pigs can fly” is TRUE! p q p→q F F T F T T T F F T T T The only False case! Topic #1.0 – Propositional Logic: Operators
  • 20. Module #1 - Logic 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 penguin.” 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
  • 21. Module #1 - Logic 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 below. p q ¬p p∧q p∨q p⊕q p→q p↔q 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

Notes de l'éditeur

  1. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank In Spring 2003 I spent 7 fifty-minute lecture periods on this material, but two half-lectures were taken up by team selection and a quiz, so it really only took 6 lectures.
  2. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  3. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank We normally attribute propositional logic to George Boole, who first formalized it. Actually the particular formal notation we will present is not precisely Boole’s; he originally spoke of logic in terms of sets, not propositions, and he also used Boolean algebra notation such as AB, A+B, rather than the A /\\ B, A \\/ B notation we will use. But, he was the first to mathematically formalize these kinds of concepts in preserved writings. Boole’s formalization of logic was developed further by the philosopher Frege. However, even though logic was not formalized as such until the 1800’s, the basic ideas of it go all the way back to the ancient Greeks. Aristotle (ca. 384-322 B.C.) developed a detailed system of logic (though one that was not quite as convenient and powerful as the modern one), and Chrysippus of Soli (ca. 281-205 B.C.) introduced a logic centered around logic AND, inclusive and exclusive OR, NOT, and implication, similarly to Boole’s. Chrysippus’ logic apparently included all of the key rules that Boole’s logic had. However, his original works were unfortunately lost; we only have fragments quoted by other authors.
  4. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  5. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  6. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank Later in the course, we will see that operators can themselves be defined in terms of functions. This slide doesn’t define them that way because we haven’t defined functions yet. But for your reference, when you come back to study this section after learning about functions, in general, an n -ary operator O on any set S (the domain of the operator) is a function O : S ^ n -> S mapping n -tuples of members of S (the operands ) to members of S . “ S ^ n ” here denotes S with n as a superscript, that is, the n th Cartesian power of S . All this will be defined later when we talk about set theory. For Boolean operators, the set we are dealing with is B={True,False}. A unary Boolean operator U is a function U:B->B, while a binary Boolean operator T is a function T:(B,B)->B. Binary operators are conventionally written in between their operands, while unary operators are usually written in front of their operands. (One exception is the post-increment and post-decrement operators in C/C++/Java, which are written after their operands.)
  7. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  8. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  9. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  10. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank Note that AND is commutative and associative, which means that we can write a long conjunction (like in the first bullet on the left) without parenthesizing it. It also doesn’t matter what order the n propositions are in. The fact that an n -operand operator has 2^ n rows in its truth table is an easy consequence of the product rule of combinatorics. Here is a proof. Note that for the table to be complete, we must have 1 row for every possible assignment of truth values to the n operands. Thus, there is 1 row for every function f : V -> B , where V is the set of operand columns { p , q ,…} and B ={T,F}. Here, | V |= n and | B |=2. The number of functions from a set of size n to a set of size m is m ^ n . This is because of the product rule, as we will see in a moment. In this case, m =2 so we get 2^ n such functions. In terms of the product rule: There are 2 possible values for p . For each of these, there are 2 possible values for q, since the choice of q is independent of the choice of p. And so on. So there are 2x2x…(n repetitions)…x2 possible rows, thus 2^ n . Of course, we haven’t defined the product rule, set cardinality, or functions yet, so don’t worry if the above argument doesn’t quite make sense to you yet. In the second bullet, we would say, {NOT,AND} is a universal set of Boolean operators, but we haven’t even defined sets yet. If you already know what a set is, a universal set of operators over a given domain is a set of operators such that nested expressions involving those operators are sufficient to express any possible operator over that domain. In this case, the domain is B={T,F}. The proof that {NOT,AND} is universal is as follows: OR can be defined by p OR q = NOT(NOT(p) AND NOT(q)) (easily verified; this is one of DeMorgan’s Laws, which we will get to later). Now, armed with OR, AND, and NOT, we can show how to express any Boolean truth table, with any number of columns, as follows. Look for the cases where the last (result) column is T. For each such row in the truth table, include a corresponding term in a disjunctive expression for the whole truth table. The term should be a conjunction of terms, one for each input operand in that row. Each of these terms should be p if the entry in that position is “T”, and NOT( p ) if the entry in that position is “F”. So, the entire expression basically says, “the value of the operator is T if and only if the pattern of truth values of the input operands exactly matches one of the rows in the truth table that ends in a ‘T’ result.” Thus, the expression directly encodes the content of the truth table.
  11. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank OR is also commutative and associative. The animated picture on the right is just a memory device to help you remember that the disjunction operator is symbolized with a downward-pointing wedge, like the blade of an axe, because it “splits” a proposition into two parts, such that you can take either part (or both), if you are trying to decide how to make the whole proposition true. Note that the meaning of disjunction is like the phrase “and/or” which is sometimes used in informal English. “The car has a bad engine and/or a bad carburetor.”
  12. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  13. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank As an exercise, drop the truth tables for f /\\ ( g \\/ s ) and ( f /\\ g ) \\/ s to see that they’re different, and thus the parentheses are necessary. Precedence conventions such as the one in the second bullet help to reduce the number of parentheses needed in expressions. Note that negation, with its tight binding (high precedence), and with its position to the left of its operand, behaves similarly to a negative sign in arithmetic. There is also a precedence convention that you see sometimes (for example, in the C programming language) that AND takes precedence over OR. However, this convention is not quite universally accepted, not all systems adopt it. Therefore, to be safe, you should always include parentheses whenever you are mixing ANDs and ORs in a single sequence of binary operators.
  14. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank For slides that have interactive exercises, it may be a good idea to stop the class for a minute to allow the students to discuss the problem with their neighbors, then call on someone to answer. This will help keep the students engaged in the lecture activity.
  15. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  16. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank A good way to remember the symbol for XOR, a plus sign inside an O, is to think of XOR as adding the bit-values of its inputs (mod 2). E.g., 0+0=0, 1+0=0, 1+1=0 (mod 2). Thus XOR is basically an addition, and we put it inside an “O” to remind ourselves that it is a type of “Or”. XOR together with unary operators do not form a universal set of operators over the Booleans. However, it turns out that they are a universal set for quantum logic! However we do not have time to cover quantum computing in this class, interesting though it is.
  17. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank
  18. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank Note that the definition of “p implies q” says: “If p is true, then q is true, and if p is not true, then q is either true or false.” Well, saying that q is either true or false is not saying anything, since any proposition is, by the very definition of a proposition, either true or false. So, the last part of that sentence (covering the case where p is not true) is not really saying anything. So we may as well say the definition is, “If p is true, then q is true.” Sometimes the antecedent is called the hypothesis and the consequent is called the conclusion .
  19. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank Let’s consider the rows of the truth table, one at a time. In the first row, p is false and q is false. Now, let’s consider the definition of p -> q . It says “If p is true, then q is true, but if p is false, then q is either true or false.” Well, in this case, p is false, and q is either true or false (namely false), so the second part of the statement is true. But, of course that part is true, since it is just a tautology that q is either true or false. In other words, and if is always true when its antecedent is false. Similarly, the second row is True. The third row is false, since p is true but q is false, so it is not the case that if p is true then q is true. Finally, in the fourth row, since p is true and q is true, it is the case that if q is true then q is true. Many students have trouble with the implication operator. When we say, “A implies B”, it is just a shorthand for “either not A, or B”. In other words, it is just the statement that it is NOT the case that A is true and B is false. This often seems wrong to students, because when we say “A implies B” in everyday English, we mean that if somehow A were to become true in some way, somehow, the statement B would automatically be thereby made true, as a result. This does not seem to be the case in general when A and B are just two random false statements (such as the example in the last bullet). (However in this case, we might make a convoluted argument that the antecedent really DOES effectively imply the consequent: Note that if 1=0, then if a given pig flies 0 times in his life, then he also flies 1 time, thus he can fly.) In any case, perhaps a more accurate and satisfying English rendering of the true meaning of the logical claim “A implies B”, might be just, “the possibility that A implies B is not contradicted directly by the truth values of A and B”. In other words, “it is not the case that A is true and B is false.” (Since that combination of truth values would directly contradict the hypothesis that A implies B.)
  20. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank The first one is true because T->T is True. It doesn’t matter that my lecture ending is not the cause of the sun rising tomorrow. The second one is false for me, because although Tuesday is a day of the week, I am most certainly NOT a penguin. (But, if a penguin were to say this statement, then it would be true for him.) The third one is true, because 1+1 is not equal to 6. F->T is True. The last one is true, because the moon is not made of green cheese. F->F is True. In other words, anything that’s false implies anything at all. p->q if p is false. Why? If p is false, then if p is true, then p is both false and true at the same time, and so truth and falsity are the same thing. So if q is false then q is true.
  21. Discrete Math - Module #1 - Logic 06/23/13 (c)2001-2002, Michael P. Frank For fun, try writing down the truth tables for each of the 4 possible unary operators, and each of the 16 possible binary operators. For each one, try to come up with an English description of the operator that conveys its meaning. Also, figure out a way to define it in terms of other operators we already introduced.