0% found this document useful (0 votes)
1 views

FM-Assignment 1

This document outlines an assignment for the Department of Software Engineering at the National University of Computer & Emerging Sciences, focusing on formal methods. It includes instructions for submission, guidelines for individual work, and several questions requiring the verification of logical statements and scenarios using propositional logic. The assignment covers topics such as truth tables, semantic entailment, and role-based access control in various scenarios.

Uploaded by

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

FM-Assignment 1

This document outlines an assignment for the Department of Software Engineering at the National University of Computer & Emerging Sciences, focusing on formal methods. It includes instructions for submission, guidelines for individual work, and several questions requiring the verification of logical statements and scenarios using propositional logic. The assignment covers topics such as truth tables, semantic entailment, and role-based access control in various scenarios.

Uploaded by

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

National University

of Computer & E m e r g i n g S c i e n c e s, I s l a m a b a d

Department of Software Engineering


(Formal Methods)

Assignment 01
Semester: Spring 2025 (FM)
Course Instructors:
Ms. Nigar Azhar Butt, Dr. Isma ul Hassam, Ms. Laiba Imran
Sections: All

Instructions
• Read the instructions very carefully.
• Late assignments will not be accepted
• Plagiarism may result in zero marks in the whole assignments category (all
assignments) regardless of the percentage plagiarized.
• There will be no credit if the given requirements are changed.
• This is an individual assignment, meaning you must complete it on your own.

Submission Guidelines

• Submit a scanned PDF of a handwritten solution for the following questions.


• Submit a separate PDF file with screenshots corresponding to the required questions.
In the screen shots make sure that your role number and name is visible.
• Submit the files with the naming convention <Rollnumber_Section>_solution.pdf and
<Rollnumber_Section>_screenshots.pdf. Eg., i22-xxxx_A_solution.pdf
Question 1:
For the following verify satisfiability and validity via complete truth tables.
1. (¬p ∧ (q → r)) → ((¬s ∨ t) ∧ (q → p))
2. ((p → q) ∧ (q → r)) → (p → r)
3. ((p → q) ∧ (r → s)) → ((p ∧ r) → (q ∧ s))
4. ((p ∧ q) ∨ (r ∧ s)) → ((p ∨ r) ∧ (q ∨ s))

Question 2:
For the following translate to Propositional Logic, and verify semantic entailment via
following:

a) Clearly describe the propositional atoms. Make sure the names of your propositional
atoms are understandable.
b) Translate premises.
c) Create the semantic entailment formula.
d) Create complete truth tables
e) Attach screenshots of SAT solver for validity and describe what the SAT solver is saying
if validity does not hold.
Scenario 1: Climate Model
Premise 1: If the climate model is accurate, the input data is reliable, and the
computational resources are sufficient, then the model will accurately predict future
climate patterns.
Premise 2: The model's predictions were inaccurate.
Premise 3: The input data is reliable.
Premise 4: The computational resources were sufficient.
Conclusion: Therefore, the climate model is inaccurate.

Scenario 2: So3ware Deployment


Premise 1: If the software is tested thoroughly and the deployment environment is
stable, then the deployment will be successful.
Premise 2: If the deployment is successful and there are no known bugs, then the
system will function correctly.
Premise 3: The deployment was not successful.
Conclusion: There were known bugs in the software.

Scenario 3: Medical Diagnosis


Premise 1: If the patient has a fever or a cough, then they are likely to have a cold.
Premise 2: If the patient has a cold and a sore throat, then they should see a doctor.
Premise 3: The patient has a fever and a sore throat.
Conclusion: The patient should see a doctor.

Scenario 4: Airbag Deployment


Premise 1: If the car crashes at a high speed and the driver is not wearing a seatbelt, the
airbag will deploy.
Premise 2: If the car crashes at a low speed and the driver is wearing a seatbelt, the
airbag will not deploy.
Premise 3: If the airbag deploys, the sensors will detect the impact.
Premise 4: The car crashed at a high speed and the driver was not wearing a seatbelt.
Premise 5: The airbag was deployed.
Conclusion: The sensors will detect the impact.

Scenario 5: Taxi
Premise 1: If the car has a flat tire or there is no gas, the driver will be late for the
appointment unless they take a taxi.
Premise 2: The driver was not late for the appointment.
Premise 3: The car had a flat tire.
Conclusion: Therefore, the driver took a taxi or there was gas.

Scenario 6: Home Security System


Premise 1: If the doors are locked and the alarm system is activated , then the house
is secure.
Premise 2: If the house is secure and there are no break-ins, then there will be no
theft.
Premise 3: There was a theft.
Premise 4: The doors are locked.
Conclusion: There was a break-in.

Question 3:
Use propositional logic to model a real-world software system and verify semantic
entailment based on logical premises. Additionally, demonstrate a case where semantic
entailment does not hold due to inconsistencies or missing conditions.
a) Select a Real-World Software System
• Choose a real-life software application such as an e-commerce platform, banking
system, hospital management system, or cloud security system.
b) Define Logical Premises (5-6 Premises)
• Identify key rules, conditions, or constraints in the chosen system.
• Express these rules using propositional logic statements.
• Example (Online Banking System):
o Premise 1: "If a user enters the correct username and password, they can log
in." translates to (p→ q) where:
§ p = "User enters correct credentials"
§ q = "User can log in"
o Premise 2: "If a user is logged in, they can access their bank account." translates
to (q→r) where:
§ r = "User can access bank account"
c) Formulate a Logical Conclusion
• Derive a conclusion based on the premises:
o Conclusion: "A user enters the correct credentials, so. they can access their
bank account." (p→r)
d) Verify Semantic Entailment
• Use Limboole or a SAT solver to verify: {(p→q),(q→r)}⊨ (p→r)
• Attach screenshots of SAT solver.
e) Modify the Premises to Introduce an Inconsistency
• Create a scenario where the logical conclusion does not follow from the premises.
• Example (Banking System - Inconsistent Rules):
o Premise 1: "If a user enters the correct credentials, they can log in." (p→q)
o Premise 2: "If a user is logged in, they can access their bank account." (q→r)
o Premise 3 (Contradiction Introduced): "Some users may log in but not have
access to their bank account." (q∧¬r)
f) Formulate a Conclusion That Fails
• Proposed Conclusion: "All users who log in can access their bank account." (q→r)
• Contradiction: Premise 3 explicitly states that some users who log in do not get access
to their account.
g) Verify That Semantic Entailment Fails
• Use Limboole or a SAT solver to check:{(p→q),(q→r),(q∧¬r)}⊨(q→r)
• Attach screenshots of SAT solver for validity
Question 4:
For the following Role-based access Control scenarios, answer the following:
1. Provide Declarative Access rules corresponding to the tables in propositional logic.
Make sure the names of your propositional atoms are understandable.
2. Provide translations of constraint to propositional logic
3. Provide formula to prove validity of constraints in context of Role-based access
controls.
4. Identify valid and invalid constraints individually and give reasons. (Use SAT solver,
no need for truth tables)
5. Incase of invalid constraints identify if and how a specification can be added that
would make it valid without changing the role based access table.

Scenario 1: Healthcare OrganizaGon

Role Patient Records Billing Appointments Prescriptions Lab Results


Doctor ✓ ✓ ✓ ✓
Nurse ✓ ✓ ✓
Medical Assistant ✓ ✓ ✓
Receptionist ✓ ✓ ✓
Lab Technician ✓

Constraints:

• Doctors, nurses and lab technician must be able to access Lab results.
• Only doctors may access prescriptions.
• A person can be Nurse and Medical assistant.
• A person cannot be a receptionist and a lab technician.
• Lab technicians can only access lab results.

Scenario 2: E-commerce PlaKorm

Role Customer Data Orders Inventory Payments Shipping


Administrator ✓ ✓ ✓ ✓ ✓
Customer Service Representative ✓ ✓ ✓ ✓ ✓
Sales Associate ✓ ✓ ✓
Warehouse Manager ✓ ✓ ✓
Shipping Coordinator ✓ ✓

Constraints:

• All users can access orders


• Only doctors may access prescriptions.
• Customer Service Representatives must not access inventory.
• A superuser must be an administrator and customer service representative.
• Only the administrator and customer service representative should have access to
payments.

Scenario 3: Manufacturing Plant


Production Quality
Role Inventory Maintenance Shipping
Planning Control
Plant Manager ✓ ✓ ✓ ✓ ✓
Production Supervisor ✓ ✓ ✓
Line Operator ✓ ✓
Quality Inspector ✓ ✓
Maintenance
X ✓ X
Technician

Constraints:

• Plant manager should be able to access all resources.


• Only Plant manager can access shipping.
• A person cannot be a Line operator and quality inspector.
• A special type of user should be possible who has role of production supervisor and
maintenance technician.

Best of Luck J

You might also like