Download presentation

1
**From Chapter 4 Formal Specification using Z David Lightfoot**

Propositional Logic From Chapter 4 Formal Specification using Z David Lightfoot

2
**Propositional calculus**

Propositional calculus is also known as Boolean algebra. Propositions in Z are either true or false. Negation can be written using bar notation In Z negation is written as ¬ (pronounced not) p ¬p false true true false

3
**Propositional calculus**

Conjunction is pronounced ‘ and’ and is written as L. p q p L q false false false false true false true false false true true true

4
**Propositional calculus**

Disjunction is pronounced ‘ or’ and is written as v. p q p v q false false false false true true true false true true true true

5
**Implication Definition**

If p and q are propositions, the compound proposition if p then q is called a conditional proposition (‘implies’) and is denoted as The proposition p is called the hypothesis (or antecedent ) and the proposition q is called the conclusion (or consequence). Can also be written as:

6
**Truth Table For Implication (Conditional Proposition)**

7
**Implication P Q “If it is raining I will wear a raincoat.”**

Statement does not say what I will do if it is not raining. Rule only covers first two cases, must apply logic of first two cases to second two cases, i.e. when its not raining raining raincoat (true) raining ¬raincoat (false) ¬raining raincoat (true) ¬raining ¬raincoat (true) To get truth value for last two cases apply (¬P v Q) (¬P v Q) P Q P Q F F T F T T T F F T T T

8
**Implication P Q is a predicate that is true if (¬P v Q) Example:**

(11 > 3) (2+2=5) is false (11>3) (2+2=4) is true P Q P Q F F T F T T T F F T T T

9
**Equivalence If p and q are propositions, the compound proposition:**

p if and only if q (sometimes written “p iff q”) it is also is called a bi-conditional proposition and is denoted by:

10
Equivalence An alternative ways to state the equivalence (or a bi-conditional proposition) are: p is equivalent to q p is a necessary and sufficient condition for q p if and only if q

11
**Truth Table For Equivalence**

12
Equivalence (P Q) (¬P v Q) ((P Q) L (Q P)) (P Q)

13
DeMorgan’s Laws ¬(P L Q) ¬P v ¬Q ¬(P v Q) ¬Q L ¬P

14
**Demonstrating Laws of Logic**

A law is a relationship which holds good irrespective of the propositions involved. The truth tables can be used to demonstrate the validity of a law. For example, to show the validity of the first of DeMorgan’s laws: ¬(P L Q) ¬P v ¬Q We complete the truth table, building towards the expressions to be compared. Write the truth table for DeMorgan’s laws in Word, using Z fonts.

15
Using Laws of Logic Laws are used to prove that two statements in the propositional calculus, that may not necessarily be identical, are equivalent. In formal specifications laws that are used in chains of transformations are called proofs which can verify that a specification is consistent and makes deductions about behaviour of a system from its specification.

16
**Order of evaluation 1. Logical connectives within brackets.**

2. Negation 3. 4 5 Where you have a choice use brackets. Associativity is left except for the conditional which is right.

17
**Logic Terminology ‘and’ is often called a Conjunction**

‘or’ is often called a Disjunction. A tautology is a proposition that is always true e.g.: (B v ¬B ) (Shakespear). A contradiction is always false e.g.: (B L¬B )

18
**Logic Terminology(Not Core)**

A Well Formed Formula (WFF). Let p,q,r.., be propositions. If we have some compound proposition (or formula) called W involving p,q,r.., whenever these variables are replace by their truth values and W becomes a proposition. Then W is a well formed formula.

19
**Logic Terminology(Not Core)**

In some cases, two different propositions may have the same truth values no matter what truth values their constituent propositions have. Such propositions are said to be logically equivalent .

20
**Logic Terminology(Not Core)**

Suppose that the compound proposition P and Q are made up of the propositions p1……pn. We say the P and Q are logically equivalent and write: given any truth values of p1……pn, either P and Q are both true or both false.

21
**Logic Terminology(Not Core)**

If P and Q are wffs, we say that P logically implies Q if any assignment of truth values to the propositions which make P true also make Q true. We write: P Q Contratrast this definition with implies, which can be defined in terms of a truth table. Difffers form Stimulus/Response and Condition/Response.

22
**Value Variable Value: a constant,no location in time or space**

Variable: holder for value, has location in time space

23
**Mathematical proof A mathematical system consists of:**

Axioms which are assumed true. Definitions which are used to create new concepts in terms of existing ones Undefined terms are not explicitly defined but are implicitly defined by axioms. A theorem is a proposition that has been proved to be true. An argument that establishes the truth of a theorem is called a proof. Logic it the tool for the analysis of proof.

24
**Logical Argument A logical argument is a sequence of propositions:**

p1 Punch is a cat p2 All cats are clever pn q Punch is clever

25
**Exercise 0 Draw the truth table for: p XOR q**

Show that the following two definitions are equivalent. p XOR q (p v q) L ¬(p L q) p XOR q (p L ¬q) v (¬p L q)

26
Exercise 1 Show by truth table that: (P Q) (¬P v Q)

27
Exercise 2 Show by truth table that: (P Q) L (Q P) (P Q)

28
**Exercise 3 By using the laws from chapter 4 simplify:**

¬(p onboard L #onboard < capacity )

29
**Exercise 3: Answer By using the laws from chapter 4 simplify:**

¬(p onboard L #onboard < capacity ) ¬(p onboard) v ¬(#onboard < capacity ) p onboard v #onboard capacity )

30
**Exercise 4 By using the laws from chapter 4 simplify:**

(a L b) v (a L c) v(a L ¬c)

31
**Exercise 4: Answer By using the laws from chapter 4 simplify:**

(a L b) v (a L c) v(a L ¬c) a L (b v c v ¬c) a L (b v true) a L true a

32
**Exercise 5 Recall from chapter 2**

1. Certain people are registered as users of a computer system. At any given time, some of these users are logged in to the computer. There is a limit (unspecified) to the number of users logged in at any one time. All users are either staff users or customers.

33
**Exercise 5 Given p loggedIn p user Check that p loggedIn L p user**

can be simplified to: p loggedIn user truth table

34
**Exercise 5 Answer Given p loggedIn p user ---- p loggedIn L p user**

Can only be true is if both sub-expressions are true Because of the given implication if p loggedIn then so is p user

35
Exercise 6 Use DeMorgan’s Laws to simplify

36
**Exercise 6:Answer Use DeMorgan’s Laws to simplify ¬(x=2 and x=6)**

Tricky ¬(x=2) V ¬(x=6) any number is either different from 2 or different from 6 Moving towards variables

37
Exercise 7 Simplify: s=t L s EOF L t EOF

38
Exercise 7 Solution Simplify: s=t L s EOF L t EOF s=t L s EOF

39
Exercise 8 Simplify: x=x L (x y v x=y)

40
Exercise 8 Solution Simplify: x=x L (x y v x=y) x y

41
Exercise 9 Simplify: x=0 L x x=0

42
Exercise 10 Simplify: ¬(age v student) age < 16 L ¬student)

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google