Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mathematics for Computing

Similar presentations


Presentation on theme: "Mathematics for Computing"— Presentation transcript:

1 Mathematics for Computing
Lecture 2: Computer Logic and Truth Tables Dr Andrew Purkiss-Trew Cancer Research UK

2 Logic Propositions Connective Symbols / Logic gates Truth Tables
Logic Laws

3 Propositions Definition: A proposition is a statement that is either true or false. Which ever of these (true or false) is the case is called the truth value of the proposition. Where the fundamental objects in arithmetic are numbers, the fundamental objects in logic are prepositions. Prepositions are statements that are either true or false. Some prepositions include statements like: Paris is the capital of France, MORE EXAMPLES FROM BOOK. Note that the statement can’t be a question, an order. There are also problems with prepositions that refer to themselves. For example the statement ‘This sentence is false’ This seems fine until we work through the possibilities and we get a paradox. For this course we will avoid self-referential logic, but this form has a place in modern logic.

4 Connectives Compound proposition e.g. ‘If Brian and Angela are not both happy, then either Brian is not happy or Angela is not happy’ Atomic proposition: ‘Brian is happy’ ‘Angela is happy’ Connectives: and, or, not, if-then Simple propositions don’t involve any logic. The logic comes from the combination of the statements into complex structures. For example, in the statement, if … . We don’t need to know if Brian or Angela are happy to see that the statement is true. The example sentence is a compound proposition. It is built up from atomic propositions with the use of connectives. The connectives are the equivalent of add, multiply in arithmetic.

5 Connective Symbols Connective Symbol and ٨ or ٧ not ~ or ¬ if-then →
if-and-only-if

6 Conjugation Logical ‘and’ Symbol ٨ Written p ٨ q
Alternative forms p & q, p . q, pq Logic gate version Logic gate form p pq q

7 Disjunction Logical ‘or’ Symbol ٧ Written p ٧ q Alternative form p + q
Logic gate version p p + q q

8 Negation Logical ‘not’ Symbol ~ Written ~p Alternative forms ¬p, p’, p
Logic gate version p ~p

9 Truth Tables p q p ٨ q T F p q p ٧ q T F p ~p T F
Truth tables describe the logical result of a proposition. We’ll go through the truth table for all the connectives we’ve seen so far.

10 Compound Propositions
~(p ٨ ~q) p q T F p q ~q p ٨~q ~(p ٨ ~q) T F p q ~q p ٨~q T F p q ~q T F Compound propositions are made by building up a compound statement by combining connectives and simple statements into a complex statement. I’ll illustrate this with a truth table. The brackets are used to give an order to the connective, so the ‘calculation’ is p and not q, all not-ed .

11 Tautologies Always true p ~p p ٧ ~p T F p ~p p ٧ ~p T F
A tautology is a proposition which is always true, regardless of the inputs. For example p or not p

12 Contradictions Always false p ~p p ٨ ~p T F
The opposite of a tautology is a contradiction. An example is p and not p. An important thing to note is that the negation of a tautology give a contradiction and vice-verse.

13 Website for Lecture Notes

14 End of First Logic 1? Place marker

15 Mathematics for Computing
Lecture 3: Computer Logic and Truth Tables 2 Dr Andrew Purkiss-Trew Cancer Research UK

16 Logical Equivalence Logical ‘equals’ Symbol ≡ Written p ≡ p p q ~p ~q
F p ٧ q T F 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.

17 Conditional Logical ‘if-then’ Symbol → Written p → q p q p → q T F
A conditional statement is of the form if p then q. and is denoted with a single arrow The conditional is only false when p is true and q false. The conditional is also frequently read as ‘p implies q’, or ‘p only q’

18 Biconditional Logical ‘if and only if’ Symbol ↔ Written p ↔ q p q
The biconditional is of the form p if and only if q Examples

19 converse and contrapositive
The converse of p → q is q → p The contrapositive of p → q is ~q → ~p Go through these two on the board

20 Laws of Logic Laws of logic allow us to combine connectives and simplify propositions and prove that logical equivalences are correct. Use truth tables to show each law, in turn

21 Double Negative Law ~ ~ p ≡ p Two ‘nots’ cancel

22 Implication Law p → q ≡ ~p ٧ q p implies q is equivalent to not p or q

23 Equivalence Law p ↔ q ≡ (p → q) ٨ (q → p)
p if and only if q is logically equivalent to (p implies q) and (q implies p)

24 Idempotent Laws p ٨ p ≡ p p ٧ p ≡ p
The idempotent laws are useful for simplification. They basically say that any proposition, combined with itself using and or or, gives rise to the original proposition

25 Commutative Laws p ٨ q ≡ q ٨ p p ٧ q ≡ q ٧ p
The commutative laws, like in normal arithmetic or algebra, mean that the order of combination doesn’t matter for the simple connectives, and and or.

26 Associative Laws p ٨ (q ٨ r) ≡ (p ٨ q) ٨ r p ٧ (q ٧ r) ≡ (p ٧ q) ٧ r
The associative laws say that when the same connective is being used more than once combining three propositions, the order doesn’t matter. Again, this is similar to simple arithmetic.

27 Distributive Laws p ٨ (q ٧ r) ≡ (p ٨ q) ٧ (p ٨ r)
The distributive law is the logical form of multiplying out the brackets in an expression. Show an example with a * (b + c) = (a * b) + (a * c)

28 Identity Laws p ٨ T ≡ p p ٧ F ≡ p
These laws give a powerful way of simplifying compound equivalences, when a part of the compound proposition simplifies to a tautology or contradication. p and true = p, p or false = p

29 Annihilation Laws p ٨ F ≡ F p ٧ T ≡ T
These laws, combining a proposition with a tautology or contradiction, destroy the proposition giving just the original tautology / contradiction

30 Inverse Laws p ٨ ~p ≡ F p ٧ ~p ≡ T
The inverse laws again give rise to a tautology / contradiction, in this case by combination of a proposition with its inverse.

31 Absorption Laws p ٨ (p ٧ q) ≡ p p ٧ (p ٨ q) ≡ p
The adsorption laws are a powerful simplification tool. They arise from the distributive laws, combined with the idempotent laws

32 de Morgan’s Laws ~(p ٨ q) ≡ ~p ٧ ~q ~(p ٧ q) ≡ ~p ٨ ~q
De Morgan’s laws are the most complex of the laws, but are useful for simplification of equations.

33 End of Logic


Download ppt "Mathematics for Computing"

Similar presentations


Ads by Google