Logic Preparation CSE
Logic Preparation CSE
1 Logic Operators 7
1.1 Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Special Propositions . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Boolean Algebra 9
2.1 Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Logic Circuits 11
3.1 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Predicate Logic 12
4.1 Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 Quantifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5 Deduction 13
5.1 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.2 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3 Verify & Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5
Logic Circuit
Is a combination of Logic Gate’s that’s able to compute a Proposition
Modus Tollens
A Premise that is false and therefore the Conclusion is also false
Modus Ponens
A Premise that is true and therefore the Conclusion is also true
Predicate
A kind of incomplete proposition, which becomes a Proposition when ap-
plied to an entity or multiple entities. With form P (x) where x is the
entity variable and P (x) the predicate
Premise
A Proposition that is known to be true or that has been accepted to be
true for the sake of an argument
Proposition
A statement consisting of Logic Operator(s)
Quantifier
Used to dictate the domain a Predicate should be valid for. There are two
quantifiers, the Universal Quantification and the Existential Quantifier.
Relay
Is an electrically operated switch. It is used where it is necessary to
control a circuit by an independent low-power signal, or where several
circuits must be controlled by one signal
Set Builder Notation
The Set Builder Notation is used to specify a set of objects by means of a
Predicate
Tautology
A Proposition that is self fullfilling and therefore always true
Transistor
Is a semiconductor device used to amplify or switch electrical signals and
power
Truth-Table
A diagram in rows and columns showing how the truth or falsity of a
Proposition varies with that of its components
Universal Quantification
Quantifier used to define that it’s valid for all: ∀x(P(x))
6
1 Logic Operators
1.1 Basic
Truth table of the basic logical operators
p q ¬p ¬q p∧q p∨q p⊕q p→q p↔q
0 0 1 1 0 0 0 1 1
0 1 1 0 0 1 1 1 0
1 0 0 1 0 1 1 0 0
1 1 0 0 1 1 0 1 1
OR
Writing p∨q using only {¬, ∧}
p q ¬p ¬q ¬p ∧ ¬q ¬(¬p ∧ ¬q) p∨q
0 0 1 1 1 0 0
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 0 1 1
XOR
Writing p⊕q using only {¬, ∧, ∨}
p q ¬p ¬q ¬p ∧ q p ∧ ¬q (¬p ∧ q) ∨ (p ∧ ¬q) p⊕q
0 0 1 1 0 0 0 0
0 1 1 0 0 1 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 0 0
Conditional
Writing p → q using only {¬, ∧, ∨}
p q ¬p ¬q ¬p ∨ q p → q
0 0 1 1 1 1
0 1 1 0 1 1
1 0 0 1 0 0
1 1 0 0 1 1
Biconditional
Writing p ↔ q using only {¬, ∧, ∨}
p q ¬p ¬q (p ∧ q) ∨ (¬p ∧ ¬q) p↔q
0 0 1 1 1 1
0 1 1 0 0 0
1 0 0 1 0 0
1 1 0 0 1 1
7
1.2 Special Propositions
There are two kinds of special propositions. Tautology which is always true
and Contradiction which is always false. By finding these cases you can simply
replace them by their logical equivalent in other words replacing a Tautology
with T and a Contradiction with F
1.3 Examples
Some examples of Propositions
p ∧ (q ⊕ r)
p ∨ (q ↔ r)
p → (q ∧ r)
p ∨ (q ∧ (r → p))
8
2 Boolean Algebra
2.1 Laws
Set of rules used to rearrange and transform statements
Double negation ¬(¬p) ≡ p
Excluded middle contradiction p ∨ ¬p ≡ T
p ∧ ¬p ≡ F
Identity laws T∧p≡p
F∨p≡p
T∨p≡T
F∧p≡F
Commutative laws p∧q ≡q∧p
p∨q ≡q∨p
Associative laws (p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
Distributive laws p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
DeMorgan’s laws ¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
Conditional laws p → q ≡ (¬p) ∨ q
(made up) ¬(p → q) ≡ p ∧ (¬q)
p ↔ q ≡ ¬(p ⊕ q)
p ∨ (p ∧ q) ≡ p
p ∧ (p ∨ q) ≡ p
2.2 Simplification
The most used method for simplifying boolean algebra expressions, which are
simple Propositions, is to use Karnaugh-maps.
9
Steps
Make a Truth-Table
2.3 Forms
Propositions can come in two forms. Either the Conjuntive Normal Form or
the Disjuntive Normal Form. Both are based around a different base operator.
Conjuntive Normal Form is based on Conjuntion(OR of AND’s) and Disjuntive
Normal Form is based on Disjuntion(AND of OR’s).
10
3 Logic Circuits
3.1 About
Logic Circuits consist of Logic Gates. Which are used to compute Propositions
automatically. This way a lot of time and human factors can be saved, especially
with more complex Propositions. There are multiple ways to build them. The
most used one being Transistors and one that could be used, but isn’t being
Relay. Basically any type of switch that takes input signals to produce an
on/off signal will do.
3.2 Types
There are two types of Logic Circuits. There is combinatorial, which has no
feedback loop. This means that the input has a direct correlations with the
output. The second type is state, which has it’s own output as one of the input.
It’s therefore state dependent.
3.3 Example
An example of Logic Gates and a Logic Circuit.
11
4 Predicate Logic
4.1 Predicates
A Predicate is a kind of incomplete proposition, which becomes a Proposition
when applied to a single Entity or multiple. The basic form is P (x) and L(x, y)
where x defines the Entity and P (x) an incomplete Proposition with an entity.
We also call a Predicate without Quantifiers an open statement. Where the
variables are called free variables. A predicate can have multiple variables.
4.2 Quantifiers
These are used to dictate the domain a Predicate should be valid for. There
are two quantifiers, they are used like ∀x(P (x)) and ∃x(P (x)). Or in the case
of multiple variables we can do ∀x(∃y(L(x, y))) which means ”for all x there is
at least one y for which L(x,y) hold”. When ambiguous like the example(when
mixing Universal Quantification and Existential Quantifier) the parentheses are
needed, otherwise they can be left out.
4.3 Laws
Important equivalence laws of predicate logic
De Morgan’s Laws ¬(∀xP (x)) ≡ ∃x(¬P (x))
for Predicate Logic ¬(∃xP (x)) ≡ ∀x(¬P (x))
Homogeneous ∀x∀yQ(x, y) ≡ ∀y∀xQ(x, y)
Quantifier Law ∃x∃yQ(x, y) ≡ ∃y∃xQ(x, y)
Heterogeneous ∀x(∃yQ(x, y)) 6≡ ∀y(∃xQ(x, y))
Quantifier Law ∃x(∀yQ(x, y)) 6≡ ∃y(∀xQ(x, y))
12
5 Deduction
5.1 About
Logic can be applied to draw Conclusions from a set of Premises. The idea is
that if you believe the Premises are true, then logic forces you to accept that
the conclusion is true. An argument is a claim that a certain conclusion follows
from said Premises. The power of deduction also lies in it’s simplicity to come
to a conclusion without having to use a Truth-Table.
5.2 Notation
The notation consists of 2 parts, the part above the line is a list of Premises, and
the part below the line is the Conclusion. The ∴ symbol is read as ’therefore’.
p
q
∴ r
There is also a rule of deduction called Law of Syllogism, used when we have a
set of implications as Premises
p→q
q→r
∴ p→r
13
6 Set Builder Notation
6.1 About
The Set Builder Notation is used to specify a set of objects by means of a
Predicate. The common notation includes 3 parts, a variable x, a vertical bar
separator, and a Predicate P (x). Which gives us S = {x|P (x)} where S denotes
the set of objects.
6.2 Notation
Symbol Description
{} indicates a set
x∈S x is an element or member of S
x∈
/S x is not an element of S
S⊆T S is a subset of T
S=T S is equal to T , equivalent to (S ⊆ T ) ∧ (T ⊆ S)
S⊂T S is a proper subset of T , equivalent to (S ⊆ T ) ∧ (T 6= S)
∅ empty set
14