0% found this document useful (0 votes)
63 views24 pages

Chapter2 Logic: by Engineer Mike

Uploaded by

Assie Pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views24 pages

Chapter2 Logic: by Engineer Mike

Uploaded by

Assie Pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Chapter2 Logic

By Engineer Mike
2.1 Propositional logic
 This logic is easiest to work with, but also has limited expressive power.
 It powers a number of applications, for instance the digital logic in chip
design.
 This takes propositions and considers how they can be combined and
manipulated.
 It finds it’s application in the design of the electric circuits that makes up
computers.
 They tire closely to the digital and the Boolean logics.
2.1.1 Prepositions
 This is a statement which is either true or false.
 The lower case letters such as p, q, and r are used to represent
propositions.
 Such letters are called Prepositional variable.
 For the rest of this discussion and class we will be using the letters p, q,
and r as our prepositional variables and they can either be true or false.
 NB: the prepositional variables are like variables in any programming
language such as java where something like int x can take any integer
value
2.1.2 Logical operators
 The logical positions are combined with the logical operators or the logical
connectives.
 They are represented by words such as ‘and’,‘or’,and ‘not’ in English.
 The logical operators corresponding to the English words are as:
 ‘and’ corresponds to ∧
 ‘or’ corresponds to ∨
 ‘not’ corresponds to ¬
Definition2.1
 Let p and q be propositions. Then p ∨ q, p ∧ q, and ¬p are propositions, whose
truth values are given by the rules:
• p ∧ q is true when both p is true and q is true, and in no other case,
• p ∨ q is true when either p is true, or q is true, or both p and q are true, and in no other
case
• ¬p is true when p is false, and in no other case
Simply put the operators
• ∧ referred to as conjunction (and)
• ∨ referred to as disjunction (or)
• ¬ referred to as negation (not)
Note:
p ∧ q is read as ‘p and q’, p ∨ q is read as ‘p or q’, and ¬p is read as ‘not p’
2.1.3 Precedence rules
 Logic operators like any mathematical operators can be used in more
complicated expression such as p∧¬q or (p∨ q)∧(q∨r).
 compound proposition is a proposition made up of simpler propositions and
logical operators.
 parentheses can be used in compound expressions to indicate the order in
which the operators are to be evaluated just like in normal mathematics.
 In absence of parentheses, the order of evaluation is determined by
precedence rules.
 The ¬ has higher precedence than ∧, and ∧ has precedence over ∨ meaning
in the absence of parentheses, any ¬ operators are evaluated first, followed
by any ∧ operators, followed by any ∨ operators.
 Example:
i. The expression ¬p∨q∧r is equivalent to the expression (¬p) ∨(q ∧r)
ii. Also the expression p∨q∧q∨r is equivalent to p ∨(q ∧q)∨r.
2.1.4 Logical equivalence
 Suppose we want to verify that, in fact, (p∧q) ∧r and p∧(q∧r) do always have the same
value.
 To do so, we have to consider all possible combinations of values of p, q, and r, and
 This is done by checking for all such combinations, the two compound expressions do
indeed have the same value.
 It is convenient to organize this computation into a truth table.
 A truth table is a table that shows the value of one or more compound propositions for
each possible combination of values of the propositional variables that they contain
 Simply it is:
 A truth table is a diagram with rows and columns showing how the true or the falsity
of a proposition varies with that of its component.
 We call each such combination a situation
A truth Table example
Fig 2.1 explanation

 The figure 2.1 is a truth table that compares the value of (p∧q)∧r to the
value of p∧(q∧r) for all possible values of p, q, and r.
 There are eight rows in the table because there are exactly eight different
ways in which truth values can be assigned to p, q, and r.
 In this table, we see that the last two columns, representing the values
of(p∧q)∧r and p∧(q∧r),are identical.
2.1.5 More logical operaters
 There are other logical operators besides ∧,∨,and¬. We will consider
 the conditional operator,→,
 The biconditional operator,↔,
 The exclusive or operator,⊕.
 These operators can be completely defined by a truth table that shows their
values for the four possible combinations of truth values of p and q.
Definition2.2.
 For any propositions p and q, we define the propositions p → q, p ↔ q, and
p⊕q according to the truth table as shown bellow:
Precedence Rules
 The exclusive or operator, ⊕, has the same precedence as ∨ (or).
 The conditional operator, →, has lower precedence than ∧ (and), ∨, ¬, and
⊕, therefore we evaluated after them.
 Finally, the biconditional operator,↔, has the lowest precedence and is
therefore evaluated last.
 For example, the expression p→ q∧r ↔¬p⊕s is evaluated as if it were
written(p→ (q∧r)) ↔ ((¬p)⊕s).
 But again you should always include the parentheses!
2.1.6 Implications in English

 The proposition p → q is called an implication or a conditional. It is usually


read as ‘p implies q’
 In such an implication p and q also get special names of their own. p is called
the hypothesis or antecedent and q is called the conclusion or consequent.
 Further more we say that if the implication p→q holds, then p is sufficient for
q. That is if p is true that is sufficient to also make q true.
 Conversely we say that q is necessary for p.
 This is to mean without q being true, it is impossible for p to be true. That is
if q is false, then p also has to be false.
Example
 In more detail. Suppose that I assert that “If Feyenoord is a great team, then
I’m the King of the Netherlands”.
 This statement has the form m → k where m is the proposition “Feyenoord is
a great team” and k is the proposition “I’m the king of the Netherlands”.
Now, demonstrably I am not the king of the Netherlands, so k is false. Since k
is false, the only way for m → k to be true is for m to be false as well.
 So, by asserting m→k, I am really asserting that the Feyenoord is not a great
team.
2.1.7 More forms of implication
 The implication ¬q →¬p is called the contrapositive of p → q.
 An implication is logically equivalent to its contrapositive.
 The contrapositive of “If this is Tuesday, then we are in Belgium” is “If we
aren’t in Belgium, then this isn’t Tuesday”.
 These two sentences assert exactly the same thing.

 Note that p → q is not logically equivalent to q → p. The implication q → p is


called the converse of p→q.
 Similarly p → q is not logically equivalent to ¬p → ¬q. The implication ¬p → ¬q
is called the inverse of p → q.
2.1.7 More forms of implication Cont.
 The biconditional operator is closely related to the conditional operator. In
fact, p↔q is logically equivalent to (p → q)∧(q → p).
 For example, if a parent tells a child, "If you are good, Sinterklaas will bring
you toys”, the parent probably really means to say “Sinterklaas will bring you
toys if and only if you are good”. (The parent would probably not respond
well to the child’s perfectly logical plea “But you never said what would
happen if I wasn’t good!”)
2.1.8 Exclusive or
 Finally, we turn to the exclusive or operator. The English word ‘or’ is actually
somewhat ambiguous.
 The two operators ⊕ and ∨ express the two possible meanings of this word
 The proposition p∨q can be expressed un ambiguously as “porq, or both”,
while p⊕q stands for “p or q, but not both”.
2.1.9 Universal operators
 any compound proposition that uses any of the operators →, ↔, and ⊕ can be
rewritten as a logically equivalent proposition that uses only ∧, ∨, and¬.
 It is easy to check that p → q is logically equivalent to ¬p ∨q. (Just make a
truth table for ¬p∨q.)
 Similarly, p↔q can be expressed as(¬p∨q)∧(¬q∨p), So, in a strict logical
sense,→, ↔,and ⊕ are unnecessary. (Nevertheless, they are useful and
important, and we won’t give them up.) go with me the pdf
 We call a set of operators that can express all operations: functionally
complete. More formally we would state the following:
 Definition 2.3. A set of logical operators is functionally complete if and only if
all formulas in propositional logic can be rewritten to an equivalent form that
uses only operators from the set.

 page 15 that I can explain further on this


2.1.10 Classifying propositions
 We define tautologies, contradictions, and contingencies as follows:
 Definition 2.4. A compound proposition is said to be a tautology if and only if
it is true for all possible combinations of truth values of the propositional
variables which it contains.
 A compound proposition is said to be a contradiction if and only if it is false
for all possible combinations of truth values of the propositional variables
which it contains.
 A compound proposition is said to be a contingency if and only if it is neither
a tautology nor a contradiction.
Definition 2.4: Cont.
 For example, the proposition ((p∨q)∧¬q) → p is a tautology. This can be
checked with a truth table:

 The fact that all entries in the last column are true tells us that this
expression is a tautology
 Note that for any compound proposition P, P is a tautology if and only if ¬P is
contradiction
Definition 2.4: Cont.

 (Here and moving forward, I use uppercase letters to represent compound


propositions. P stands for any formula made up of simple propositions,
propositional variables, and logical operators.)
 Logical equivalence can be defined in terms of tautology:
Definition2.5.

 Two compound propositions, P and Q, are said to be logically equivalent if


and only if the proposition P↔ Q is a tautology.
 The assertion that P is logically equivalent to Q will be expressed symbolically
as ‘P≡ Q’. For example, (p→q) ≡ (¬p∨q),and p⊕q≡ (p∨q)∧¬(p∧q).
 What if P → Q and P is false? From a false premise we can derive any
conclusion(check the truth table of→). So if k stands for “I’m the King of the
Netherlands”, then k → Q is true for any compound proposition Q. You can
substitute anything for Q, and the implication k → Q will hold. For example, it
a logically valid deduction that: If I’m the King of the Netherlands, then
unicorns exist. Taking this further, from a contradiction we can derive any
conclusion. This is called the Principle of Explosion
2.2.1 Basics of Boolean Algebra
2.5 Deduction
  Logic can be applied to draw conclusions from a set of premises.
 A premise is just a proposition that is known to be true or that has been
accepted to be true for the sake of argument, and a conclusion is a
proposition that can be deduced logically from the premises.
 The idea is that if you believe that 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 a given set of
premises.
 Here is an argument laid out in a traditional format:

You might also like