# Logic Circuits, Axioms for Basic Logic

(論理回路, 基本論理の公理化)

## Discrete Mathematics I

### 5th lecture, Oct. 13, 2017

http://www.sw.it.aoyama.ac.jp/2017/Math1/lecture5.html

### Martin J. Dürst # Today's Schedule

• Schedule for next few weeks
• Summary of last lecture
• Last week's homework
• XOR, NAND, NOR, and logical circuits
• Axioms for basic logic
• Equivalence and implication
• This week's homework

# Lunchtime Concert

Today, 12:40-13:10, Wesley Capel, Horn and Organ

# Schedule for the Next Few Weeks

• October 13 (today): Logic Circuits, Axioms for Basic Logic
• October 20: No lecture (overseas conference)
• October 27: Predicate Logic, Quantifiers
• November 3: No lectures (Aoyama Festival)
• November 10: Application of Predicate Logic
• (weekly lectures after this date)

# Summary of Last Lecture

• There are many laws for logical operations. These laws can be used to manipulate and simplify logical formulæ, and to prove additional laws.
• Most laws come in pairs that are related by the duality principle.
• Each logical (Boolean) function can be represented in two normal forms:
• Disjunctive normal form: Disjunction of conjunction (of negation) of variables
• Conjunctive normal form: Conjunction of disjunction (of negation) of variables
• Normal forms can be simplified by symbol manipulation or by using a Karnaugh map

# Last Week's Homework

If you have a problem with accessing the course's web site or submitting your homework, please contact me immediately by email.

111 submissions (out of 128 students)

Grading is mostly manual and will take some time.

# XOR, NAND, and NOR

Boolean functions other than and, or, and not used frequently in programs and electronic circuits:

• XOR (exclusive or)
• defined as true if either A or B is true, but not both
• written A xor B , AB
• widely used in encryption/cryptography
• NAND
• defined as ¬(AB)
• written as NAND(A, B) or AB
• widely used in electronic circuits and flash memory
• NOR
• defined as ¬(AB)
• written as NOR(A, B) or AB
• widely used in electronic circuits and flash memory

XOR NAND NOR
A B AB AB AB
F F F T T
F T T T F
T F T T F
T T F F F

# Logic Circuits

• Boolean functions can be calculated (evaluated) using logic circuits
• The relationship between logic formulæ and electric (electronic) circuits was established by Claude Shannon in his 1938 master thesis
• The components of a logic circuit are called gates
• Gates are connected with wires
• The output of a gate is the input of (an)other gate(s)
• For logic circuits, 1 and 0 are often used in place of true and false

# Gates Used in Logic Circuits

 NOT gate AND gate OR gate XOR gate NAND gate NOR gate

# Example of a Logic Circuit

Half adder (to add two binary numbers, two half adders and an OR gate per binary digit (bit) are necessary)

 input output A B C (carry) S (sum) 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0

# How to Write Logic Circuits

• Input from the left, output to the right
• Write variable name or formula for each input/output
• Make clear where crossing lines (wires) touch and where not
• AND, NAND, OR, and NOR gates may use more than two inputs

# Property of NAND and NOR

Theorem: It is possible to implement all boolean functions using only NAND [or only NOR]

Proof:

We know that we can write any boolean function using only ∧, ∨, and ¬ (using a normal form)

If we can write these three boolean operations using only NAND [or only NOR], our proof is complete.

¬ A = NAND(A) [NOR(A)] (alternatively: AA [AA])

AB = ¬¬(AB) = NAND(¬(AB)) = NAND(NAND(A, B))
[= ¬¬(AB) = ¬(¬A ∨ ¬B) = NOR(¬A, ¬B) = NOR(NOR(A), NOR(B))]

AB = ¬¬(AB) = ¬(¬A ∧ ¬B) = NAND(¬A, ¬B) = NAND(NAND(A), NAND(B))
[= ¬¬(AB) = NOR(¬(AB)) = NOR(NOR(A, B))]

Q.E.D.

Comment: This is a constructive proof. It is often used for theorems of the form "it is possible...".

Comment: This property is important because it is easier to construct a logical circuit where all the gates are the same (e.g. all NAND).

# Axiomatization

• An axiom is a theorem that is assumed to be true, without proof.
• One goal of mathematics is to create rich, beautiful (and useful) theories from very few axioms.
• In lecture 2, we introduced the Peano Axioms for the arithmetic of natural numbers.
All provable properties of natural numbers can be proven from these very few axioms.
• Can we find axioms for basic logic?
• Important properties for axioms:
• Consistent: No contradictions
• Complete: Possible to derive any true theorem
• Minimal: Impossible to remove any axiom
• Simple: Low number of axioms and operators, short
• Obvious to humans

# Axiomatizations of Basic Logic

• Standard axioms:
AB=BA [+D]; A∧(B∨¬B)=A [+D];
A∨(BC)=(AB)∧(AC) [+D]
• Huntington axioms (1904):
A∨F = A [+D]; AB=BA [+D];
A∨(BC)=(AB)∧(AC) [+D]; A∨¬A=T [+D]
• Huntington axioms (1933):
AB=BA; A∨(BC)=(AB)∨C;
¬(¬AB)∨¬(¬A∨¬B)=A
• Robbins axioms (proposed 1933, proved automatically 1996):
AB=B∨A; A∨(BC)=(AB)∨C;
(¬(¬(AB)∨¬(A∨¬B))=A
• Sheffer axioms (1913?):
(AA)⊼(AA)=A; A⊼(B⊼(BB))=AA;
(A⊼(BC))⊼(A⊼(BC))=((BB)⊼A)⊼((CC)⊼A)
• Wolfram axiom (found automatically 2002):
(AB)⊼C)⊼(A⊼((AC)⊼A))=C

(for more axiomatizations, see http://www.cs.unm.edu/~veroff/BA/)

Comment: [+D] indicates that the dual is also an axiom

# Evaluation of Axiomatizations

 Con­sis­tent? Com­plete? Mini­mal? Simple? Obvi­ous? Axi­oms Op­er­a­tors Overall Length Standard yes yes yes 6 3 very long yes Huntington 1904 yes yes yes 8 3 very long yes Huntington 1933 yes yes yes 3 2 short no Robbins yes yes yes 3 2 short no Sheffer yes yes yes 3 1 long no Wolfram yes yes yes 1 1 very short no

# Conclusion from Evaluation of Axiomatizations

• For natural number arithmetic (Peano axioms),
there are axiom systems that are both simple and obvious
• For plane geometry (Euclid's axioms),
there are axiom systems that are both simple and obvious
• For basic logic:
• There are axiom systems that are simple (but not obvious)
• There are axiom systems that are obious (but not simple)
• There is no axiom system that is both simple and obvious

# Logical Operations Important for Symbolic Logic

• Equivalence: AB (read: A is equivalent to B)
If and only if A and B have the same value (both T or both F), then AB is T.
• Implication: AB (read: A implies B)
If A is T and B is F, then AB is F, otherwise AB is T.

# Truth Table for Equivalence and Implication

Equivalence Implication
A B AB AB
F F T T
F T F T
T F F F
T T T T

# Example of Implication

A: "I will pass Discrete Mathematics I."

B: "I will travel to Okinawa next Spring."

AB: "Me passing Discrete Mathematics I implies that I will travel to Okinawa next Spring."
or: "If I will pass Discrete Mathematics I, I will travel to Okinawa next Spring."

# Laws of Implication and Equivalence

1. Rewriting (removing) implication: AB = ¬AB = ¬(A∧¬B)
2. Rewriting (removing) equivalence: AB = (AB)∧(BA) = (AB)∨(¬A∧¬B)
3. Transitive laws: ((AB) ∧ (BC)) ⇒ (AC),
((AB) ∧ (BC)) ⇒ (AC)
4. Reductio ad absurdum: A→¬A = ¬A
5. Contraposition: AB = ¬B→¬A
6. Properties of equivalence: AB = ¬A↔¬B, ¬(AB) = (A↔¬B)
7. Properties of implication: T→A = A, F→A = T, A→T = T, A→F = ¬A

## Caution:

There is a difference between "→" and "⇒".

"→" is an operator of boolean/symbolic logic. "→" can be manipulated like any other operator (e.g. +, -, ×, ÷ in basic arithmetic).

"⇒" tells us humans that we can replace formulæ that match the form on its left side with formulæ that match its right side.

The same difference exists between "↔" and "=".

# How to Use a Truth Table for a Proof

• Goal: Prove one of the absorbtion laws for ∨ and ∧: AAB = A.
• Method:
1. Create a truth table for both sides of the law.
2. Compare the columns for both sides
(light green column and light blue column).
3. If the columns are equal, the law is proved.
• Alternative:
1. As above, but add a column that combines both sides of the law with ↔.
2. Check that the additional column contains all Ts (i.e. the formula is a tautology)
A B AB AAB AABA
F F F F T
F T F F T
T F F T T
T T T T T

# This Week's Homework

Deadline: October 19, 2017 (Thursday), 19:00.

Format: A4 single page (using both sides is okay; NO cover page), easily readable handwriting (NO printouts), name (kanji and kana) and student number at the top right

Where to submit: Box in front of room O-529 (building O, 5th floor)
(There are several boxes, please make sure to use the correct one.)

# Problem One

For each of the 16 Boolean functions of two Boolean variables A and B (same as problem 1 of last week), find the shortest formula using only NOR.
You can use NOR with any number of arguments ≧1, but you cannot use T or F.

Hint: Start with simple formulæ using NAND and find out which functions they represent.

# Problem Two

Draw logic circuits of the following three Boolean formulæ:

1. AB ∨ ¬C
2. NAND(G, XOR(H, K), H)
3. NOR(E, ¬F) ∧ G

# Problem Three

(no need to submit/提出不要)

Create examples for implication and think about why the truth table for implication is the way it is.

(含意の例を作って、含意の真理表と実例を比較して含意を身に着ける。)

# Additional Homework

Deadline: October 26, 2017 (Thursday), 19:00.

Format: A4 single page (using both sides is okay; NO cover page), easily readable handwriting (NO printouts), name (kanji and kana) and student number at the top right

Where to submit: Box in front of room O-529 (building O, 5th floor)

Problem 1: Prove/check the following laws using truth tables:

1. Reductio ad absurdum (A→¬A = ¬A)
2. Contraposition
3. The associative law for disjunction
4. One of De Morgan's laws

Problem 2: Prove transitivity of implication (((AB) ∧ (BC)) ⇒ (AC)) by formula manipulation. For each step, indicate which law you used.
Hint: Show that ((AB) ∧ (BC)) → (AC) is a tautology by simplifying it to T.

# Glossary

grading

exclusive or

encryption

cryptography

(electronic) circuit
(電子) 回路
logic circuit

master thesis

gate
ゲート
half adder

bit (binary digit)
ビット
variable name

implement

theorem

constructive proof

axiomatization

complete(ness)

consisten(t/cy)

contradiction

obvious(ness)

symbolic logic

equivalence

x is equivalent to y
x と y が同値である
implication

x implies y
x ならば y
pass (some course)
(ある科目を) 合格する
rewriting (removing) implication

rewriting (removing) equivalence

transitive laws

reductio ad absurdum

contraposition

properties of equivalence

properties of implication

tautology