You are on page 1of 10

Formal Methods

The exclusive or operator

• If somebody were to say I will go to the theatre or I will go to the cinema, it is likely that what is meant is
that the person will go to either the theatre or the cinema, but not to both.
• The natural language ‘or’ usually implies that only one or other of the statements is TRUE but not both.
• This corresponds to the logical operator known as exclusive or (sometimes referred to as xor), which is
represented by the symbol .
COMPOUND STATEMENTS AND THE ORDER OF PRECEDENCE OF
OPERATORS

• Ambiguity can easily arise in compound statements that contain more than one proposition. Consider, for
example, the statement: P and Q or R.
• This could be evaluated in two ways: we could evaluate P ˄ Q, and then evaluate the disjunction of this value
with R; alternatively, we could evaluate Q ˅ R, and then evaluate the conjunction of this value with P.
TAUTOLOGY
• A statement which is always TRUE (that is, all the rows of the truth table evaluate to TRUE) is called a
tautology.
Contradiction
• A statement which is always FALSE (i.e. all rows of the truth table evaluate to FALSE) is called a
contradiction.
THREE-VALUED LOGIC
• Classical logic assumes that all expressions evaluate to TRUE or FALSE. In reality, this is not always the
case when evaluating an expression, because sometimes an expression can be undefined.
• Undefined terms are very common in programming situations – for example, when a variable is first declared
and has not yet been assigned a value.
• In three valued logic system of a proposition could have the value TRUE, FALSE or UNDEFINED.
Predicate Logic
• One of the limitations with the propositional logic is that, while it allows us to argue about individual values,
it does not give us the ability to argue about sets of values.
• A set is any well-defined, unordered, collection of objects.
• The set containing all the people who work in a particular office; the set of whole numbers from 1 to 10; the
set of the days of the week.
• The name of the set denoted by an upper-case letter and the elements by lower-case letters.
• A = {s, d, f, h, k}

• B = {a, b, c, d, e, f}

• The symbol € means ‘is an element of’. Therefore the statement ‘d is an element of A’ is written: d € A
• The statement ‘p is not an element of A’ is written: p € A
Predicate
• Predicates can be named with either a single letter, or with a word that expresses the meaning of the
predicate; the variables are placed in brackets after the name. This is made clear in the following examples:
• C(x): x is a cat
• Studies(x,y): x studies y
• Prime(n): n is a prime number
• A statement such as C(x) can be read C of x.
BINDING VARIABLE
• Predicates such as those above do not yet have a value – they only have a value when the variables
themselves are given a value. There are two ways in which this can be done.
• By substitution (giving a value to the variable) For example, using the above three predicates:
• C(Simba): Simba is a cat
• Studies(Olawale, physics): Olawale studies physics
• Prime(3): 3 is a prime number
Practice

You might also like