CS 202, Spring 2008 Epp, sections 1.1 and 1.2

Slides:



Advertisements
Similar presentations
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Advertisements

1 Section 1.2 Propositional Equivalences. 2 Equivalent Propositions Have the same truth table Can be used interchangeably For example, exclusive or and.
1 Section 1.1 Logic. 2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller.
22C:19 Discrete Math Introduction and Scope Propositions Fall 2011 Sukumar Ghosh.
The Foundations: Logic and Proofs
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
Propositions and Truth Tables
The Foundations: Logic and Proofs
2009/9 1 Logic and Proofs §1.1 Introduction §1.2 Propositional Equivalences §1.3 Predicates and Quantifiers §1.4 Nested Quantifiers §1.5~7 Methods of Proofs.
CS 285- Discrete Mathematics Lecture 2. Section 1.1 Propositional Logic Propositions Conditional Statements Truth Tables of Compound Propositions Translating.
Chapter 1 The Logic of Compound Statements. Section 1.1 Logical Form and Logical Equivalence.
CSci 2011 Textbook ^Discrete Mathematics and Its Applications,  Rosen  6th Edition  McGraw Hill  2006.
Review I Rosen , 3.1 Know your definitions!
Chap. 2 Fundamentals of Logic. Proposition Proposition (or statement): an declarative sentence that is either true or false, but not both. e.g. –Margret.
(CSC 102) Lecture 3 Discrete Structures. Previous Lecture Summary Logical Equivalences. De Morgan’s laws. Tautologies and Contradictions. Laws of Logic.
1 Boolean Logic CS 202, Spring 2007 Epp, sections 1.1 and 1.2 Aaron Bloomfield.
CS 2210 (22C:019) Discrete Structures Introduction and Scope: Propositions Spring 2015 Sukumar Ghosh.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, November 2015Introduction & Propositional Logic 1.
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Lecture 9 Conditional Statements CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Chapter 1: The Foundations: Logic and Proofs
1 Boolean Logic CS/APMA 202, Spring 2005 Rosen, section 1.1 Aaron Bloomfield.
CSci 2011 Recap ^Propositional operation summary not andorconditionalBi-conditional pq ppqqpqpqpqpqpqpqpqpq TTFFTTTT TFFTFTFF FTTFFTTF FFTTFFTT.
Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
Discrete Mathematics Lecture # 4. Conditional Statements or Implication  If p and q are statement variables, the conditional of q by p is “If p then.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
CS104 The Foundations: Logic and Proof 1. 2 What is Discrete Structure?  Discrete Objects  Separated from each other (Opposite of continuous)  e.g.,
Law of logic Lecture 4.
Propositional Logic. Logic Logic: the science of reasoning, proof, thinking or inference. Logic allows us to analyze a piece of reasoning and determine.
2. The Logic of Compound Statements Summary
Propositional Equivalences
22C:19 Discrete Structures Introduction and Scope: Propositions
The Foundations: Logic and Proofs
DISCRETE MATHEMATICS CHAPTER I.
CS 2210:0001 Discrete Structures Introduction and Scope: Propositions
CSNB 143 Discrete Mathematical Structures
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
COMP 1380 Discrete Structures I Thompson Rivers University
6/20/2018 Arab Open University Faculty of Computer Studies M131 - Discrete Mathematics 6/20/2018.
COT 3100, Spr Applications of Discrete Structures
(CSC 102) Discrete Structures Lecture 2.
Ch.1 (Part 1): The Foundations: Logic and Proofs
Boolean Algebra A Boolean algebra is a set B of values together with:
Discrete Mathematics Lecture # 2.
Mathematics for Computing
The Foundations: Logic and Proofs
Principles of Computing – UFCFA3-30-1
Propositional Logic.
Fundamentals of Logic Sentence: A sentence is usually collection of words Proposition: A proposition is usually a declarative to which it is meaningful.
CSCI 3310 Mathematical Foundation of Computer Science
Propositional Calculus: Boolean Algebra and Simplification
Propositional Equivalences
Information Technology Department
Propositional Equivalence (§1.2)
CS 220: Discrete Structures and their Applications
CS201: Data Structures and Discrete Mathematics I
Propositional Equivalences
CS 220: Discrete Structures and their Applications
Applied Discrete Mathematics Week 1: Logic
Discrete Mathematics Lecture # 3.
Cs Discrete Mathematics
Foundations of Discrete Mathematics
The Foundations: Logic and Proofs
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Discrete Structures Prepositional Logic 2
CS201: Data Structures and Discrete Mathematics I
The Foundations: Logic and Proofs
Presentation transcript:

CS 202, Spring 2008 Epp, sections 1.1 and 1.2 Boolean Logic CS 202, Spring 2008 Epp, sections 1.1 and 1.2

Applications of Boolean logic Computer programs And computer addition Logic problems Digital design Sudoku

Boolean propositions A proposition is a statement that can be either true or false “The sky is blue” “I is a Engineering major” “x == y” Not propositions: “Are you Bob?” “x := 7” Propositions A proposition is a statement that can be either true or false Today is my birthday The sky is blue My major is computer science Some examples of statements that are not propositions: What day is today? Come here! x = x – 5 Some statements that are questionable… This is blue Depends on whether “this” is understood from the context We use Boolean variables to refer to propositions Named after George Boole, hence why it is always capitalized Boolean variables usually are lower case letters starting with p (i.e. p, q, r, s, etc.) A Boolean variable can have one of two values true (T) or false (F) Sometimes true is represented by 1, and false by 0 A proposition can be… A single variable: p An operation of multiple variables: p٨(q٧~r)

Boolean variables We use Boolean variables to refer to propositions Usually are lower case letters starting with p (i.e. p, q, r, s, etc.) A Boolean variable can have one of two values true (T) or false (F) A proposition can be… A single variable: p An operation of multiple variables: p(qr)

Introduction to Logical Operators About a dozen logical operators Similar to algebraic operators + * - / In the following examples, p = “Today is Friday” q = “Today is my birthday” Introduction to Logical Operators About a dozen logical operators Similar to algebraic operators + * - / In the following examples, p = “Today is Friday” q = “Today is my birthday”

Logical operators: Not A not operation switches (negates) the truth value Symbol:  or ~ In C++ and Java, the operand is ! p = “Today is not Friday” p p T F Logical operators: Not Like the minus sign for making an integer negative A not operation switches (negates) the truth value A not operand is the only unary operand It operates on a single variable, rather than on two Symbol: Ø or ~ In C++ and Java, the operand is ! If p = “Today is Friday”, then ~p = “Today is not Friday”

Logical operators: And An and operation is true if both operands are true Symbol:  It’s like the ‘A’ in And In C++ and Java, the operand is && pq = “Today is Friday and today is my birthday” p q pq T F Logical operators: And An and operation is true if both operands are true Symbol: ٨ It’s like the ‘A’ in And Also called a conjunction by the textbook In C++ and Java, the operand is && Let p = “Today is Friday” and q = “Today is my birthday” p٨q = “Today is Friday and today is my birthday”

Logical operators: Or An or operation is true if either operands are true Symbol:  In C++ and Java, the operand is || pq = “Today is Friday or today is my birthday (or possibly both)” p q pq T F Logical operators: Or An or operation is true if either operands are true Symbol: ٧ In English, or usually means one or the other. In logic, it means one or the other or both. Also called a disjunction by the textbook In C++ and Java, the operand is || Let p = “Today is Friday” and q = “Today is my birthday” p٧q = “Today is Friday or today is my birthday (or possibly both)”

Logical operators: Exclusive Or An exclusive or operation is true if one of the operands are true, but false if both are true Symbol:  Often called XOR pq  (p  q)  ¬(p  q) In Java, the operand is ^ (but not in C++) pq = “Today is Friday or today is my birthday, but not both” p q pq T F Logical operators: Exclusive Or An exclusive or operation is true if one of the operands are true, but not if both are true Symbol: Å Often called XOR In English, this is what people often mean when they say “or” In Java, the operand is ^ (but not in C++) Let p = “Today is Friday” and q = “Today is my birthday” pÅq = “Today is Friday or today is my birthday, but not both” Thus, regular or is called “inclusive” or, as it includes the case where both are true

Inclusive Or versus Exclusive Or Do these sentences mean inclusive or exclusive or? Experience with C++ or Java is required Lunch includes soup or salad To enter the country, you need a passport or a driver’s license Publish or perish Inclusive Or versus Exclusive Or Do these sentences mean inclusive or exclusive or? Experience with C++ or Java is required (OR) Lunch includes soup or salad (XOR) To enter the country, you need a passport or a driver’s license (OR) Publish or perish (XOR)

Logical operators: Nand and Nor The negation of And and Or, respectively Symbols: | and ↓, respectively Nand: p|q  ¬(pq) Nor: p↓q  ¬(pq) p q pq pq p|q pq T F Logical operators: Nand and Nor The negation of And and Or, respectively Symbols: | and ↓, respectively Nand: p|q = ¬(p ٨ q) Nor: p↓q = ¬(p٧q)

Logical operators: Conditional 1 A conditional means “if p then q” Symbol:  pq = “If this class is easy, then I’ll get an A” p→q  ¬pq p q pq ¬pq T F Logical operators: Conditional 1 An conditional means “if p then q” Symbol: ® Let p = “Today is Friday” and q = “Today is my birthday” p®q = “If today is Friday, then today is my birthday” the antecedent the consequence

Logical operators: Conditional 2 Let p = “I am elected” and q = “I will lower taxes” I state: p  q = “If I am elected, then I will lower taxes” Consider all possibilities Note that if p is false, then the conditional is true regardless of whether q is true or false p q pq T F Logical operators: Conditional 2 Let p = “I am elected” and q = “I will lower taxes” Let’s assume I am running for office, and I state: p ® q = “If I am elected, then I will lower taxes” Consider all possibilities: If both I am elected and I lower taxes, then my statement p ® q is true If I am elected but I do not lower taxes, then my statement p ® q is false If I am not elected, whether I lower taxes or not does not matter (for keeping my oath) – I said I would lower taxes if I was elected, and since I wasn’t elected, I didn’t have to keep my promise Thus, if p is false, then the conditional is true regardless of whether q is true or false

Logical operators: Conditional 3 Inverse Converse Contra-positive p q p q pq pq qp qp T F Logical operators: Conditional 3 We can change the order of the antecedent (p) and the consequence (q), and negate them Original is the conditional if this is then today is my birthday Inverse negates the truth values if this class is not easy then I did not get an A Converse switches the order if I got an A then this class is easy Contra-positive does both if I did not get an A then this class is not easy Note that the truth values of the conditional and the contra-positive are the same Note that the truth values of the inverse and the converse are the same

Logical operators: Conditional 4 Alternate ways of stating a conditional: p implies q If p, q p is sufficient for q q if p q whenever p q is necessary for p Logical operators: Conditional 4 Alternate ways of stating a conditional: p implies q If p, q p only if q p is sufficient for q q if p q whenever p q is necessary for p

Logical operators: Bi-conditional 1 A bi-conditional means “p if and only if q” Symbol:  Alternatively, it means “(if p then q) and (if q then p)” pq  pq  qp Note that a bi-conditional has the opposite truth values of the exclusive or p q pq T F Logical operators: Bi-conditional 1 A bi-conditional means “p if and only if q” Alternatively, it means “(if p then q) and (if q then p)” Symbol: « Note that a bi-conditional has the opposite truth values of the exclusive or

Logical operators: Bi-conditional 2 Let p = “You take this class” and q = “You get a grade” Then pq means “You take this class if and only if you get a grade” Alternatively, it means “If you take this class, then you get a grade and if you get a grade then you take (took) this class” p q pq T F Logical operators: Bi-conditional 2 Let p = “You take this class” and q = “You get a grade” Then p«q means “You take this class if and only if you get a grade” Alternatively, it means “If you take this class, then you get a grade and if you get a grade then you take (took) this class”

Boolean operators summary Learn what they mean, don’t just memorize the table! not and or xor nand nor conditional bi-conditional p q p q pq pq pq p|q pq pq pq T F Boolean operators summary No need to copy this down – the list will be given as a handout next class Why all these operators? We can make up a total of 2^4=16 different operators Some are used by computers, some by humans, some by proofs

Precedence of operators Just as in algebra, operators have precedence 4+3*2 = 4+(3*2), not (4+3)*2 Precedence order (from highest to lowest): ¬   → ↔ The first three are the most important This means that p  q  ¬r → s ↔ t yields: (p  (q  (¬r))) ↔ (s → t) Not is always performed before any other operation Precedence of operators Just as in algebra, operators have precedence 4+3*2 = 4+(3*2), not (4+3)*2 Precedence order (from highest to lowest): ¬ ٨ ٧ → ↔ The first three are the most important This means that p ٧ q ٨ ¬ r → s ↔ t yields: (p ٧ (q ٨ (¬r))) ↔ (s → t)

Translating English Sentences Problem: p = “It is below freezing” q = “It is snowing” It is below freezing and it is snowing It is below freezing but not snowing It is not below freezing and it is not snowing It is either snowing or below freezing (or both) If it is below freezing, it is also snowing It is either below freezing or it is snowing, but it is not snowing if it is below freezing That it is below freezing is necessary and sufficient for it to be snowing pq p¬q ¬p¬q pq p→q (pq)(p→¬q) p↔q Translating English Sentences In real life, you would choose p and q For this class, it is easier to grade it if we supply what p and q are Problem: p = “It is below freezing” q = “It is snowing” Examples: It is below freezing and it is snowing p ٨ q It is below freezing but not snowing p٨ ¬q “but” means “and” It is not below freezing and it is not snowing ¬p٨ ¬q It is either snowing or below freezing (or both) p٧q The “or both” means inclusive or If it is below freezing, it is also snowing p→q It is either below freezing or it is snowing, but it is not snowing if it is below freezing (p٧q)٨(p→¬q) This one's a doozy! That it is below freezing is necessary and sufficient for it to be snowing p↔q Note that “necessary and sufficient” means the bi-conditional

Translation Example 1 Heard on the radio: A study showed that there was a correlation between the more children ate dinners with their families and lower rate of substance abuse by those children Announcer conclusions: If children eat more meals with their family, they will have lower substance abuse If they have a higher substance abuse rate, then they did not eat more meals with their family Translation Example 1 Heard on the radio: A study showed that there was a correlation between the more children ate dinners with their families and lower substance abuses of those children Here “more” was defined as 7 dinners a week, or so Announcer concludes: If children eat more meals with their family, they will have lower substance abuse If they have a higher substance abuse rate, then they did not eat more meals with their family Many ways to debunk this (in particular, correlation means causation) We're going to use logic

Translation Example 1 Let p = “Child eats more meals with family” Let q = “Child has less substance abuse Announcer conclusions: If children eat more meals with their family, they will have lower substance abuse p  q If they have a higher substance abuse rate, then they did not eat more meals with their family q  p Note that p  q and q  p are logically equivalent

Translation Example 1 Let p = “Child eats more meals with family” Let q = “Child has less substance abuse” Remember that the study showed a correlation, not a causation p q result conclusion T F ? Translation Example 2 Let p = “Child eats more meals with family” Let q = “Child has less substance abuse” Only the two highlighted values were shown Announcer concluded that it was a bi-conditional We need to know if the other two are true “It is not the case where a child eats more meals a day and has more substance abuse” “It is not the case that when the child does not eat more means with their family, that there is less substance abuse”

Translation Example 2 “I have neither given nor received help on this exam” Rephrased: “I have not given nor received …” Let p = “I have given help on this exam” Let q = “I have received help on this exam” Translation is: pq p q p pq T F

Translation Example 2 What they mean is “I have not given and I have not received help on this exam” Or “I have not (given or received) help on this exam” The problem:  has a higher precedence than  in Boolean logic, but not always in English Also, “neither” is vague p q pq (p  q) T F

Bit Operations 1 Boolean values can be represented as 1 (true) and 0 (false) A bit string is a series of Boolean values 10110100 is eight Boolean values in one string We can then do operations on these Boolean strings Each column is its own Boolean operation Bit Operations Boolean values can be represented as 1 (true) and 0 (false) A bit string is a series of Boolean values 10110100 is eight Boolean values in one string We can then do operations on these Boolean strings Each column is its own Boolean operation 01011010 10110100 11101110

Bit Operations 2 Evaluate the following 01011 11011 11011 11000 11000  (01011  11011) = 11000  (11011) = 11000 01011 11011 11011 11000 11011 Bit Operations 2 Evaluate the following 11000 ٨ (01011 ٧ 11011) = 11000 ٨ (11011) = 11000

&& vs. & in C/C++ This evaluates to zero (false)! Consider the following: In C/C++, any value other than 0 is true The binary for the integer 11 is 01011 The binary for the integer 20 is 10100 int p = 11; int q = 20; if ( p && q ) { } if ( p & q ) { Notice the double ampersand – this is a Boolean operation As p and q are both true, this is true Notice the single ampersand – this is a bitwise operation && vs. & in C/C++ Consider the following: int p = 23; int q = 40; if ( p && q ) { } if ( p & q ) { In C/C++, any value other than 0 is true The binary for the integer 23 is 01011 The binary for the integer 40 is 10100 Notice the double ampersand – this is a Boolean operation As p and q are both true, this is true Notice the single ampersand – this is a bitwise operation Bitwise Boolean And operation: 01011 ٨10100 00000 This evaluates to zero (false)! 01011 10100 00000 This evaluates to zero (false)! Bitwise Boolean And operation:

&& vs. & in C/C++ Note that Java does not have this “feature” If p and q are int: p & q is bitwise p && q will not compile If p and q are boolean: Both p & q and p && q will be a Boolean operation The same holds true for the or operators (| and ||) in both Java and C/C++ && vs. & in C/C++ Note that Java does not have this “feature” If the types of p and q are int: p & q will be a bitwise operation p && q will not compile If the types of p and q are Boolean: Both p & q and p && q will be a Boolean operation The same holds true for the or operators (| and ||) in both Java and C/C++

Tautology and Contradiction A tautology is a statement that is always true p  ¬p will always be true (Negation Law) A contradiction is a statement that is always false p  ¬p will always be false (Negation Law) Tautology and Contradiction A tautology is a statement that is always true p Ú ¬p will always be true (Negation Law) “The sky is blue or the sky is not blue” A contradiction is a statement that is always false p Ù ¬p will always be false (Negation Law) “The sky is blue and the sky is not blue” p p  ¬p p  ¬p T F

Logical Equivalence A logical equivalence means that the two sides always have the same truth values Symbol is ≡or  We’ll use ≡, so as not to confuse it with the bi-conditional Logical Equivalence A logical equivalence means that the two sides always have the same truth values Symbol is ≡ or Û (we’ll use ≡)

Logical Equivalences of And p  T ≡ p Identity law p  F ≡ F Domination law p T pT F Logical Equivalences of And Identity law Domination law p F pF T

Logical Equivalences of And p  p ≡ p Idempotent law p  q ≡ q  p Commutative law p pp T F p q pq qp T F Logical Equivalences of And Idempotent law Commutative law

Logical Equivalences of And (p  q)  r ≡ p  (q  r) Associative law p q r pq (pq)r qr p(qr) T F Logical Equivalences of And Associative law

Logical Equivalences of Or p  T ≡ T Identity law p  F ≡ p Domination law p  p ≡ p Idempotent law p  q ≡ q  p Commutative law (p  q)  r ≡ p  (q  r) Associative law Logical Equivalences of Or Identity law Domination law Idempotent law Commutative law Associative law

Corollary of the Associative Law (p  q)  r ≡ p  q  r (p  q)  r ≡ p  q  r Similar to (3+4)+5 = 3+4+5 Only works if ALL the operators are the same! Corollary of the Associative Law (p Ù q) Ù r ≡ p Ù q Ù r (p Ú q) Ú r ≡ p Ú q Ú r Similar to (3+4)+5 = 3+4+5

Logical Equivalences of Not ¬(¬p) ≡ p Double negation law p  ¬p ≡ T Negation law p  ¬p ≡ F Negation law Logical Equivalences of Not Double negation law Negation law

DeMorgan’s Law Probably the most important logical equivalence To negate pq (or pq), you “flip” the sign, and negate BOTH p and q Thus, ¬(p  q) ≡ ¬p  ¬q Thus, ¬(p  q) ≡ ¬p  ¬q p q p q pq (pq) pq pq (pq) pq T F DeMorgan’s Law Probably the most important logical equivalence To negate p Ù q (or p Ú q), you “flip” the sign, and negate BOTH p and q Thus, ¬(p Ù q) ≡ ¬p Ú ¬q Thus, ¬(p Ú q) ≡ ¬p Ù ¬q

Yet more equivalences Distributive: Absorption p  (q  r) ≡ (p  q)  (p  r) p  (q  r) ≡ (p  q)  (p  r) Absorption p  (p  q) ≡ p p  (p  q) ≡ p Yet more equivalences Distributive: p Ú (q Ù r) ≡ (p Ú q) Ù (p Ú r) p Ù (q Ú r) ≡ (p Ù q) Ú (p Ù r) Absorption p Ú (p Ù q) ≡ p p Ù (p Ú q) ≡ p

How to prove two propositions are equivalent? Two methods: Using truth tables Not good for long formulae In this course, only allowed if specifically stated! Using the logical equivalences The preferred method Example: show that: How to prove two propositions are equivalent? Two methods: Using truth tables Not good for long formula Using the logical equivalences Example: show that: ..

Using Truth Tables (pq) →r pq (p→r)(q →r) q →r p→r r q p p q r p→r F

Using Logical Equivalences Original statement Definition of implication DeMorgan’s Law Associativity of Or Re-arranging Using Logical Equivalences Original statement Definition of implication DeMorgan’s Law Associativity of Or Re-arranging Idempotent Law Idempotent Law

Logical Thinking At a trial: Bill says: “Sue is guilty and Fred is innocent.” Sue says: “If Bill is guilty, then so is Fred.” Fred says: “I am innocent, but at least one of the others is guilty.” Let b = Bill is innocent, f = Fred is innocent, and s = Sue is innocent Statements are: ¬s  f ¬b → ¬f f  (¬b  ¬s) Logical Thinking At a trial: Bill says: “Sue is guilty and Fred is innocent.” Sue says: “If Bill is guilty, then so is Fred.” Fred says: “I am innocent, but at least one of the others is guilty.” Let b = Bill is innocent, f = Fred is innocent, and s = Sue is innocent Statements are: ¬s Ù f ¬b → ~f f Ù (¬b Ú ¬s)

Can all of their statements be true? Show: (¬s  f)  (¬b → ¬f)  (f  (¬b  ¬s)) ¬b ¬f ¬s ¬b→¬f f(¬b¬s) ¬b¬s ¬sf s f b b f s ¬b ¬f ¬s ¬sf ¬b→¬f ¬b¬s f(¬b¬s) T F Are all of their statements true? Show: (¬s Ù f) Ù (¬b → ¬f) Ù (f Ù (¬b Ú ¬s)) Via truth table

Are all of their statements true Are all of their statements true? Show values for s, b, and f such that the equation is true Original statement Definition of implication Associativity of AND Re-arranging Idempotent law Absorption law Distributive law Negation law Domination law Are all of their statements true? Show values for s, b, and f such that the equation is true

Functional completeness All the “extended” operators have equivalences using only the 3 basic operators (and, or, not) The extended operators: nand, nor, xor, conditional, bi-conditional Given a limited set of operators, can you write an equivalence of the 3 basic operators? If so, then that group of operators is functionally complete

Functional completeness of NAND Show that | (NAND) is functionally complete Equivalence of NOT: p | p ≡ p (p  p) ≡ p Equivalence of NAND (p) ≡ p Idempotent law

Functional completeness of NAND Equivalence of AND: p  q ≡ (p | q) Definition of nand p | p How to do a not using nands (p | q) | (p | q) Negation of (p | q) Equivalence of OR: p  q ≡ (p  q) DeMorgan’s equivalence of OR As we can do AND and OR with NANDs, we can thus do ORs with NANDs Thus, NAND is functionally complete