3rd Leacture Formal Methods in Software Engineering
3rd Leacture Formal Methods in Software Engineering
Engineering
Instructor: Abdul Wahab
Lecture 3
Logic
What is Logic?
In computer science, the aim of the logic is to develop a language that models a
situation, in which, it can reason formally to realize the desired objective.
Example of Logic:
Premise 1: All humans are mortal.
Premise 2: Ali is a human.
Conclusion: Therefore, Ali is mortal.
In this example, if the premises are true, then the conclusion must also be true. This structure
of reasoning is a classic example of deductive logic. It shows how we can arrive at a
conclusion based on established truths.
Reasoning
What is Reasoning?
Reasoning is a process of using existing knowledge or observations to make predictions or
draw conclusions.
Reasoning is the process of thinking about something in a logical way to form conclusions,
inferences, or judgments. It involves analyzing information, identifying relationships between
concepts, and drawing logical connections.
Types of Reasoning:
Deductive Reasoning: Starts with general statements (premises) and derives specific conclusions.
For example:
Premise 1: All birds have feathers.
Premise 2: A sparrow is a bird.
Conclusion: Therefore, a sparrow has feathers.
Inductive Reasoning:
Begins with specific observations and makes generalizations. For example:
•Observation: The sun has risen in the east every day I’ve seen.
•Conclusion: Therefore, the sun always rises in the east.
Abductive Reasoning: Involves forming the best possible explanation based on incomplete information.
For example:
•Observation: The grass is wet.
•Conclusion: It probably rained last night.
Propositional are statements that are either True or False. Propositional maybe combined using logical
connectives
Propositional logic is based on propositions and propositional formulas, which are written in a
propositional language.
Propositional Logic (PL) is a formal language, which is often used in behavior analysis of computing
systems.
PL is based on mathematical modelling that can be used to perform reasoning about the truthfulness or
falsehood of logical expressions.
The core idea of propositional logic is to develop a language to model the situation in a manner where
reasoning can be performed formally to express properties of a system.
True: The proposition that is always true is represented by T (or 1).
False: The proposition that is always false is represented by F (or 0).
Connectives
¬ or ~ negation (not)
^ Conjunction (and)
∨ Disjunction (or)
⇒ Implication (Implies or only if)
⇔Equivalence(iff or if and only if)
Why Propositional Logic?
Most of modern formal specifications and proofs are performed with the use of
propositional logic and predicate logic.
Propositional logic is a useful tool for modelling and reasoning in diverse application
domains, especially in digital circuits
Predicate Logic:
For example:
Suppose M is the predicate representing “man is mortal” and let x be a variable. Then
M(x) is an atomic formula meaning “x is mortal.”
Atomic proposition or Atomic Formula
Atomic proposition (or atomic formula) is the simplest type of proposition in propositional
logic that cannot be broken down into smaller components. It consists of a single statement
that is either true or false, without any logical connectives.
Examples :
p: "It is raining."
q: "The sky is blue."
In each case, the statement is a simple assertion that can be evaluated as true or false.
For example, in the compound proposition p ∧q (which means "It is raining and the sky is
blue"), p and q are atomic propositions.
Propositions / sentences express the atomic concepts about the world.
Propositional Variables: Propositions / sentences are represented by propositional
variables such p, q, r, … For example; p: The sun is shining
Example
2+2=5
Tomorrow= Tuesday
Example
Proposition: A = It is raining.
Possible value: true or false therefore in a truth table.
Conjunction is an operation on two logical values, typically the values of two propositions,
that produces a value of true if and only if (also known as iff) both of its operands are true.
The conjunction of propositions p and q is denoted by p ^ q
Conjunction Example P v (Q ^ R)
Implication
In p → q there does not need to be any connection between the antecedent or the
consequent. The meaning depends only on the truth values of p and q.
Implication Example p → (q → r)
Bi-implication / equivalence
If p and q are propositions, then bi-implication proposition p ↔ q has this truth table
Tautology
if it is always true.
When all results in the truth table are true
Example: p ∨ ¬p.
A formula is satisfiable if it holds under some or all assignments, which means the truth
values of conclusion, some values are true and some values are false.