0% found this document useful (0 votes)
12 views22 pages

3rd Leacture Formal Methods in Software Engineering

The document discusses the principles of logic and reasoning in software engineering, focusing on propositional logic and its applications. It explains various types of reasoning, including deductive, inductive, and abductive reasoning, and introduces propositional logic as a formal language for modeling and reasoning about systems. Additionally, it covers logical connectives, atomic propositions, and the concepts of tautology, contradiction, and satisfiability.

Uploaded by

amansyed44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views22 pages

3rd Leacture Formal Methods in Software Engineering

The document discusses the principles of logic and reasoning in software engineering, focusing on propositional logic and its applications. It explains various types of reasoning, including deductive, inductive, and abductive reasoning, and introduces propositional logic as a formal language for modeling and reasoning about systems. Additionally, it covers logical connectives, atomic propositions, and the concepts of tautology, contradiction, and satisfiability.

Uploaded by

amansyed44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Formal Methods in Software

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.

Reasoning is essential for problem-solving, decision-making, and understanding complex ideas.

 Due to basic techniques of logical formalisms, formal methods were born.


 Formal methods are used in the industry with their specification languages, theorem proving, and model checking
What is Propositional Logic?

 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:

 A predicate logic is an expression of one or more variable defined on some specific


domain

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

 Jaffa cakes are biscuits.

 Your cat is rich.

 Your dog is good looking.

 2+2=5

 Tomorrow= Tuesday
Example

 ¬ (Jaffa cakes are biscuits)

 Your cat is rich ^Your dog is good looking.

 The map is wrong ∨ You are a poor navigator

 (2 + 2 = 5) ⇒ (UNEMPLOYMENT < 2 MILLION)

 (Tomorrow = Tuesday ) ⇔ (Today = Monday)


Compound Proposition

 Compound proposition are constructed from simple proposition


 Two or more propositions are joined using logical connectives
 In formal methods, the natural language is scan for propositions.
Each proposition (either True or false) will be translated into an expression usually
joined using operators.
Translating English sentences to statement
in propositional logic
 Identify atomic propositions and represent using propositional variables.
 Determine appropriate logical connectives
Example;
 “If time is 8:00-9:30 am and room CS003 is occupied, then Formal method class is going
on.”
 p: time is 8:00-9:30 am
 q: room CS003 is occupied.
 r: Formal method class is going on.
If p and q then r. ➔ p^q → r
Precedence of logical Connectives in PL
Negation

 Proposition: A = It is raining.
 Possible value: true or false therefore in a truth table.

 Proposition: ⌐A = It is not raining or Not (It is raining).


 Possible value: true or false therefore in a truth table.
Disjunction

 In the semantics of logic, classical disjunction is a truth functional operation which


returns the truth value "true" unless both of its arguments are "false“
 The disjunction of propositions p and q is denoted by p ∨ q
 Disjunction Example :(P v Q) v R
Conjunction

 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

 If p and q are propositions, then p → q is a conditional statement or implication which is


read as “if p, then q” and has this truth table:
Implication

 In p → q, p is the hypothesis (antecedent) and q is the conclusion (or consequence)

 Implication can be expressed by disjunction and negation: p → q ≡ ¬p ∨ q

 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

p ↔ q also reads as:


 p if and only if q
 p iff q.
 Equivalence Example : (p → q) ^ (q → p)
Tautology and Contradiction

 Tautology
 if it is always true.
 When all results in the truth table are true
 Example: p ∨ ¬p.

 Contradiction /Un- Satisfiability


 if it always false.
 When all results in the truth table are false
 Example: p ∧ ¬p.
Satisfiability

 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.

 It may be possible that all values are true.

You might also like