Logic Circuits,
Axioms for Basic Logic
(論理回路, 基本論理の公理化)
Discrete Mathematics I
5th lecture, October 21, 2021
https://www.sw.it.aoyama.ac.jp/2022/Math1/lecture5.html
Martin J. Dürst

© 2005-22 Martin
J. Dürst Aoyama Gakuin
University
Today's Schedule
- 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
Schedule for the Next Few Weeks
- October 21 (today): Logic Circuits, Axioms for Basic Logic
- October 27, 18:40: Deadline for this week's homework
- October 28: No lectures (Aoyama Festival)
- November 2, 18:40: Deadline for additional homework
- November 4: Intermediate test, sets
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
Grading is partly manual and will take some time.
Homework Problem One
List all the possible Boolean functions of two variables A and
B in a table. Use one row for each Boolean function. Find the/a
simplest formula (using ¬, ∧, and ∨).
- Solution (logical operators that we will look at from now on are given in
[]):
- [solution removed]
Last Week's Homework: Problem Two
- Create a truth table for a Boolean function with four variables
(A, B, C, D).
- Decide on the result (truth value, T or F) for each row of the truth
table with a random function.
- As a random function, use e.g. a coin toss.
- Decide which side of the coin corresponds to which truth value
(e.g. Japanese 500-yen coin: 500 side → true; flower side → false)
- Toss the coin as many times as necessary (16
times).
- Your Boolean function will be different from the Boolean function of all
other students.
- If your Boolean function is the same as that of another student, there
will be some deduction.
- Calculate the two normal forms and a simplified formula for your Boolean
function.
The solution is different for each student!
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, XOR(A,
B) A ⊕ B
- widely used in encryption/cryptography
- NAND
- defined as ¬(A ∧ B)
- written as NAND(A, B) or A ⊼
B
- widely used in electronic circuits and flash memory
- NOR
- defined as ¬(A ∨ B)
- written as NOR(A, B) or A ⊽
B
- widely used in electronic circuits and flash memory
Truth Tables for XOR, NAND, and NOR
|
|
XOR |
NAND |
NOR |
| A |
B |
A ⊕ B |
A ⊼ B |
A ⊽ B |
| 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 Logic Circuit: Half Adder
Half adder (to add two binary numbers, two half adders and an OR gate per
binary digit (bit) are necessary; this is called a full adder)
| inputs |
outputs |
| 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, and connection
- Make clear where crossing lines (wires) touch and where not
- AND, NAND, OR, and NOR gates may use more (or less) than two inputs
Examples:
AND(A, B, C) = A ∧ B ∧ C
NOR(A, B, C, D) = ¬(A ∨ B ∨ C ∨
D) ≠ A ⊽ B ⊽ C ⊽
D
OR(A) = A
NAND(A) = ¬A
Example Logic Circuit: Full Adder
| inputs |
outputs |
| A |
B |
Cin (carry in) |
Cout (carry out) |
S (sum) |
| 0 |
0 |
0 |
0 |
0 |
| 0 |
0 |
1 |
0 |
1 |
| 0 |
1 |
0 |
0 |
1 |
| 0 |
1 |
1 |
1 |
0 |
| 1 |
0 |
0 |
0 |
1 |
| 1 |
0 |
1 |
1 |
0 |
| 1 |
1 |
0 |
1 |
0 |
| 1 |
1 |
1 |
1 |
1 |
Formulæ:
Cout = A∧B ∨
Cin∧XOR(A, B)
S = XOR(XOR(A, B),
Cin)
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: A⊼A
[A⊽A])
A ∧ B = ¬¬(A ∧
B) = NAND(¬(A ∧
B)) = NAND(NAND(A,
B))
[= ¬¬(A ∧ B) =
¬(¬A ∨ ¬B) = NOR(¬A, ¬B) =
NOR(NOR(A), NOR(B))]
A ∨ B = ¬¬(A ∨
B) = ¬(¬A ∧
¬B) = NAND(¬A,
¬B) = NAND(NAND(A),
NAND(B))
[= ¬¬(A ∨
B) = NOR(¬(A ∨ B)) = 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...". A constructive proof shows
how 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 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:
A∨B=B∨A [+D];
A∧(B∨¬B)=A [+D];
A∨(B∧C)=(A∨B)∧(A∨C)
[+D]
- Huntington axioms (1904):
A∨F = A [+D];
A∨B=B∨A [+D];
A∨(B∧C)=(A∨B)∧(A∨C)
[+D]; A∨¬A=T [+D]
- Huntington axioms (1933):
A∨B=B∨A;
A∨(B∨C)=(A∨B)∨C;
¬(¬A∨B)∨¬(¬A∨¬B)=A
- Robbins axioms (proposed 1933, proved automatically 1996):
A∨B=B∨A;
A∨(B∨C)=(A∨B)∨C;
¬(¬(A∨B)∨¬(A∨¬B))=A
- Sheffer axioms (1913):
(A⊼A)⊼(A⊼A)=A;
A⊼(B⊼(B⊼B))=A⊼A;
(A⊼(B⊼C))⊼(A⊼(B⊼C))=((B⊼B)⊼A)⊼((C⊼C)⊼A)
- Wolfram axiom (found automatically 2002):
(A⊼B)⊼C)⊼(A⊼((A⊼C)⊼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
|
Consistent? |
Complete? |
Minimal? |
Simple? |
Obvious? |
| Axioms |
Operators |
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, there in an axiom system
that is both simple and obvious (Peano axioms)
- For plane geometry, there is an axiom system
that is both simple and obvious (Euclid's axioms)
- For basic logic:
- There are axiom systems that are simple (but not obvious)
- There are axiom systems that are obvious (but not simple)
- There is no axiom system that is both simple and obvious
Logical Operations Important for Symbolic Logic
Truth Table
|
|
Equivalence |
Implication |
| A |
B |
A ↔ B |
A → B |
| F |
F |
T |
T |
| F |
T |
F |
T |
| T |
F |
F |
F |
| T |
T |
T |
T |
- Equivalence: A ↔ B (read: A is
equivalent to B; also: A if and only if B,
A iff B)
If and only if A and B have the same value (both T or
both F), then A ↔ B is T.
- Implication: A → B (read: A implies
B)
If A is T and B is F, then A →
B is F, otherwise A → B is T.
Example of Implication
A: "I will pass Discrete Mathematics I."
(antecedent)
B: "I will travel to Okinawa next Spring."
(consequent)
A → B: "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."
Implication is True if Antecedent is False
- Assume you meet your friend in April 2023, receiving a small gift from
Okinawa. Your friend went to Okinawa.
- Question: Did your friend pass Discrete Mathematics I?
- Answer: We do not know. (The implication did not say
what happens if your friend does not pass Discrete Mathematics
I.)
- There are other cases where there are differences between everyday talk
and strict logic meaning of implication.
Laws of Implication and Equivalence
- Rewriting (removing) implication: A→B =
¬A∨B = ¬(A∧¬B)
- Rewriting (removing) equivalence: A↔B =
(A→B)∧(B→A) =
(A∧B)∨(¬A∧¬B)
- Transitive laws: ((A→B) ∧
(B→C)) ⇒ (A→C),
((A↔B) ∧ (B↔C)) ⇒
(A↔C)
- Reductio ad absurdum: A→¬A = ¬A
- Contraposition: A→B =
¬B→¬A
- Properties of equivalence: A↔B =
¬A↔¬B, ¬(A↔B) =
(A↔¬B)
- Properties of implication: T→A = A,
F→A = T, A→T = T, A→F =
¬A
Difference between → and ⇒
There is a difference between "→" and "⇒".
"→" is an operator of boolean/symbolic logic. "→" can be manipulated
like any other operator (e.g. ∧, ∨, ¬,...).
"⇒" tells humans that we can replace (or have replaced) formulæ
that match the form on its left side with formulæ that match its right
side.
This is best visible in the transitive law for implication:
((A→B) ∧ (B→C)) ⇒
(A→C)
The same difference exists between "↔" and "=".
How to Use a Truth Table for a Proof, Method 1
Goal: Prove one of the absorption laws for ∨ and ∧: A∨A∧B
= A.
- Create a truth table for both sides of the law.
- Compare the columns for both sides
(light green column and light blue column).
- If the columns are equal, the law is proved
(always explicitly state this).
| A |
B |
A ∧ B |
A ∨
A∧B |
| F |
F |
F |
F |
| F |
T |
F |
F |
| T |
F |
F |
T |
| T |
T |
T |
T |
Because the columns for A and for A ∨
A∧B are identical, the absorption law is proven.
How to Use a Truth Table for a Proof, Method 2
Goal: Prove one of the absorption laws for ∨ and ∧:
A∨A∧B = A.
- Create a truth table for both sides of the law.
- Add a column that combines
both sides of the law with ↔: A∨A∧B
↔ A
- Check that the additional column contains all Ts (i.e. the formula is a
tautology)
(always explicitly state this).
| A |
B |
A ∧ B |
A ∨ A∧B |
A∨A∧B
↔ A |
| F |
F |
F |
F |
T |
| F |
T |
F |
F |
T |
| T |
F |
F |
T |
T |
| T |
T |
T |
T |
T |
The proof is complete because the last column only contains Ts.
Tautology and Contradiction
- A Boolean formula that is always true is called a
tautology.
- A Boolean formula that is always false is called a
contradiction.
- All laws are tautologies, but there are also tautologies that we do not
call laws.
(Example: T→A = ¬¬A)
Announcement
There will be a longer test (~30 minutes) on November
4th.
Please prepare by repeating the contents of all the
lectures up to now
(including homework, English/Japanese terms,...)
This Week's Homework
Submission: Deadline: October 27 (Thursday), 18:40; Place:
Box in front of room O-529; format: Single page, A4 (both
sides okay, legible handwriting (NO printouts), name (incl.
reading) and student number at top right)
Problem 1: Express Boolean functions with NOR only:
For each of the 16 Boolean functions of two Boolean variables A
and B (same as problem 1 of last lecture), find the shortest formula
using only NOR. In your answers, you can use NOR with any number of arguments
≧1, but you cannot use T or F.
Hint: Start with simple formulæ using NOR and find out which functions they
represent.
Problem 2: Draw logic circuits for the following three Boolean
formulæ:
- A ∨ C ∧ ¬B
- NAND(K, NOR(H, K), H)
- XOR(¬E, H) ∧ 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: Proofs of Logic Formulæ
Submission: Deadline: November 2
(Wednesday), 18:40; Place: Box in front of room O-529; format:
Single page, A4 (both sides okay, legible
handwriting (NO printouts), name (incl. reading) and student number at top
right)
Problem 1: Prove/check the following laws using truth tables:
- Reductio ad absurdum (A→¬A = ¬A)
- Contraposition
((A→B)→(¬B→¬A))
- The associative law for conjunction
- One of De Morgan's laws
Problem 2: Prove transitivity of implication by formula manipulation:
Prove transitivity of implication (((A→B) ∧
(B→C)) ⇒ (A→C)) by formula
manipulation. For each step, indicate which law you used.
Hint: Show that ((A→B) ∧
(B→C)) → (A→C) is a tautology
by simplifying it to T.
Details: Multiple parallel applications of the same law can be done in one
step. Multiple sequential applications of the same law should be separated into
different steps. Application of commutativity and associativity laws can be
combined in one step.
Preparation for Next Lecture
(no need to submit)
In preparation for next week's lecture, using your high school
books/materials or other sources, research the following terms related to sets,
and write a definition and short explanation for each of them:
Set, element, set union, set intersection, set difference, subset, proper
subset, empty set, universal set, power set
(高校の本・資料などの情報を活用して、上記の集合に関連する概念を調査し、定義と簡単な説明を書きなさい。)
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
- antecedent
- 前件
- consequent
- 後件
- pass (some course)
- (ある科目を) 合格する
- rewriting (removing) implication
- 含意の除去
- rewriting (removing) equivalence
- 同値の除去
- transitive laws
- 推移律
- reductio ad absurdum
- 背理法
- contraposition
- 対偶
- properties of equivalence
- 同値の性質
- properties of implication
- 含意の性質
- tautology
- 恒真式
-