Presentation is loading. Please wait.

Presentation is loading. Please wait.

Concepts of Computation

Similar presentations


Presentation on theme: "Concepts of Computation"— Presentation transcript:

1 Concepts of Computation
Session 3a Logic Dr Oded Lachish (Slides prepared with the support of Dr Paul Newman and Eva Szatmari)

2 Logic: Topics to be covered
Equivalence Replacement principle

3 Logical Equivalence Logical ‘equivalent’ Symbol ≡ Written p ≡ p
In the case of the example we have just seen: ~(~p ٨ ~q) ≡ p ٧ q We’ll now move onto the algebra of logic. First the idea that two expressions have the same meaning. If two expressions, using the same variables, give the same truth values for every combination of truth values for the input variables, they are said to be logically equivalent. For example ‘It is not the case that both Andy and Rachael are not in the flat.’ And ‘Either Andy or Rachael are in the flat’ Let p be ‘Andy is in the flat’ let q be ‘Rachael is in the flat’ Two expressions are logically equivalent if the yield the same truth table.

4 Equivalence, versus equals and if and only if
Compound Proposition = T Means that the values of the atomic propositions in the compound proposition are such that the compound Proposition is True. Example, p ٨ q = T means that both p = T and q = T (check the look up table) p ٨ q = F ,means that either p = F or q = F or both (check the look up table) Note: the compound proposition p ٨ q is not equivalent to True or to False We will show next useful examples of equivalence. Note that if you replace the equivalence symbol with the equals the meaning changes completely.

5 Binary Logic Identities

6 Summary: Binary Logic Identities
Law First version Second version Double Negative ~ ~ p ≡ p - Idempotent p ٨ p ≡ p p ٧ p ≡ p Identity p ٨ T ≡ p p ٧ F ≡ p Annihilation p ٨ F ≡ F p ٧ T ≡ T Inverse p ٨ ~p ≡ F p ٧ ~p ≡ T Commutative p ٨ q ≡ q ٨ p p ٧ q ≡ q ٧ p Associative p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r p ٧ (q ٧ r) ≡ (p ٧ q) ٧ r Distributive p ٨ (q ٧ r) ≡ (p ٨ q) ٧ (p ٨ r) p ٧ (q ٨ r) ≡ (p ٧ q) ٨ (p ٧ r) Absorption p ٨ (p ٧ q) ≡ p p ٧ (p ٨ q) ≡ p Implication p → q ≡ ~p ٧ q Equivalence p ↔ q ≡ (p → q) ٨ (q → p) de Morgan’s ~(p ٨ q) ≡ ~p ٧ ~q ~(p ٧ q) ≡ ~p ٨ ~q We will illustrate with truth tables

7 Tautologies p ~p p ٧ ~p T F Always true
A tautology is a proposition which is always true, regardless of the inputs. For example p or not p (see later) NB Normally would break here, and have tutorial week 2

8 Contradictions p ~p p ٨ ~p T F Always false
The opposite of a tautology is a contradiction. An example is p and not p. (see later) An important thing to note is that the negation of a tautology give a contradiction and vice-versa.

9 Laws of Logic Laws of logic allow us to combine connectives and simplify propositions. We will illustrate with truth tables

10 Double Negative Law ~ ~ p ≡ p

11 Double Negative Law ~ ~ p ≡ p p T F

12 Double Negative Law ~ ~ p ≡ p p ~p T F

13 Double Negative Law ~ ~ p ≡ p p ~p ~~p T F

14 Commutative Laws p ٨ q ≡ q ٨ p
p ٧ q ≡ q ٧ p Same law as arithmetic: = 1 + 2 Same as arithmetic

15 Commutative Laws p q p ٨ q q ٨ p T F p q p ٧ q q ٧ p T F p ٨ q ≡ q ٨ p
Same as arthimetic

16 Commutative Laws p q p ٨ q q ٨ p T F p q p ٧ q q ٧ p T F p ٨ q ≡ q ٨ p
Same as arthimetic

17 Commutative Laws p q p ٨ q q ٨ p T F p q p ٧ q q ٧ p T F p ٨ q ≡ q ٨ p
Same as arthimetic

18 Associative Laws p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r p ٧ (q ٧ r) ≡ (p ٧ q) ٧ r

19 Associative Laws p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r p ٧ (q ٧ r) ≡ (p ٧ q) ٧ r
Same law as seen in algebra (order of brackets irrelevant): 2 x (3 x 4) = (2 x 3) x 4 [ = 24]

20 Associative Laws p q r (q ٨ r) p ٨ (q ٨ r) T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Left side p q r (q ٨ r) p ٨ (q ٨ r) T F

21 Associative Laws p q r (q ٨ r) p ٨ (q ٨ r) T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Left side p q r (q ٨ r) p ٨ (q ٨ r) T F

22 Associative Laws p q r (q ٨ r) p ٨ (q ٨ r) T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Left side p q r (q ٨ r) p ٨ (q ٨ r) T F

23 Associative Laws p q r (p ٨ q) (p ٨ q) ٨ r T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Right side p q r (p ٨ q) (p ٨ q) ٨ r T F

24 Associative Laws p q r (p ٨ q) (p ٨ q) ٨ r T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Right side p q r (p ٨ q) (p ٨ q) ٨ r T F

25 Associative Laws p q r (p ٨ q) (p ٨ q) ٨ r T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Right side p q r (p ٨ q) (p ٨ q) ٨ r T F

26 Associative Laws p q r p ٨ (q ٨ r) (p ٨ q) ٨ r T F
p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r Both sides p q r p ٨ (q ٨ r) (p ٨ q) ٨ r T F Both sides give the same result

27 Example of two compound propositions that are not equivalent
p → q p ↔ q T F If there is one example where the tables are different, then the propositions are not equivalent

28 The replacement principle

29 What do you think about this proposition
p ٨ q ٨ q ٨ q ٨ q ٨ q ٨ r ٨ s This is equivalent to p ٨ q ٨ r ٨ s , but using a truth table to verify this requires a lot of effort. We know that q ٨ q ≡ q, from the identity table we have. This is good, because if these two propositions are equivalent, then we can replace q ٨ q by q like we do next and get an equivalent compound proposition, a proposition with one less q. By repeating this again and again, as formally written below, we are left with an equivalent proposition with only one q. p ٨ q ٨ q ٨ q ٨ (q ٨ q) ٨ r ٨ s ≡ p ٨ q ٨ q ٨ (q ٨ q) ٨ r ٨ s ≡ p ٨ q ٨ (q ٨ q) ٨ r ٨ s ≡ p ٨ (q ٨ q) ٨ r ٨ s ≡ p ٨ q ٨ r ٨ s

30 The replacement principle
The replacement principle means that in a compound proposition, we can replace part of a proposition by something equivalent to it. We can only do that if we add parenthesis according to the order of operations and that part is exactly surrounded by parenthesis! p ٨ q ٧ q Here we can’t replace q ٧ q by q, despite the identity q ٧ q ≡ q, because ٨ has precedence over ٧, and hence with parenthesis we have p ٨ q ٧ q ≡ (p ٨ q) ٧ q In the compound proposition p ٨ (q ٧ q ), we can do so p ٨ (q ٧ q ) ≡ p ٨ q Check that p ٨ (q ٧ q ) and (p ٨ q) ٧ q are not equivalent (use truth tables) Recall that ٨ is like multiplication and٧ is like addition.

31 The replacement principle
When can we use the replacement law: We can only use an identity if the part of the part of the proposition we want to exchange can be put in parenthesis For example: q ٧ p ٨ p ≡ q ٧ (p ٨ p) (check the precedence table), So, we can use the identity p ٨ p ≡ p for replacement here to get q ٧ p ٨ p ≡ q ٧ (p ٨ p) ≡ q ٧ p However, p ٧ p ٨ q ≡ p ٧ (p ٨ q) So, we cannot use the identity p ٧ p ≡ p for replacement here, because we cannot put parenthesis around p ٧ p in p ٧ (p ٨ q)


Download ppt "Concepts of Computation"

Similar presentations


Ads by Google