Formal Method Detailed Assignment
Formal Method Detailed Assignment
Submitted By:
Name: Moneeb Mushtaq
Roll No: 07
Subject: Formal Method
Department: BS-SE 5th
Session: 2021-2025
• Load academia-1.als.
• Realism Conditions and Default Scopes
• Model Under constrained.
• Check Assertions:
• Verify any assertions present in the model.
The Code:
-- Signatures --
abstract sig Person {}
sig Faculty extends Person {}
abstract sig Student extends Person {}
sig Graduate, Undergrad extends Student {}
sig Instructor in Person {}
sig Course {
taughtby: one Instructor,
enrolled: some Student,
waitlist: set Student}
-- Fact --
fact {
-- All instructors are either Faculty or Graduate Students
all i: Instructor | i in Faculty + Graduate
-- No one is waiting for a course unless someone is enrolled
all c: Course | some c.waitlist => some c.enrolled
-- Graduate students do not teach courses they are enrolled in
-- or waiting to enroll in
all c: Course | c.taughtby !in c.enrolled + c.waitlist
}
-- Realism Constraints
pred RealismConstraints [] {
-- There is a graduate student who is an instructor
some Graduate & Instructor
-- There are at least two courses
#Course >= 2
-- Assertions
assert NoWaitingTeacher {
all c: Course | no (c.taughtby & c.waitlist)}
check NoWaitingTeacher for 10
assert NoEnrolledAndWaiting {
all c: Course | no (c.enrolled & c.waitlist)}
check NoEnrolledAndWaiting for 10
2. Exercise 2
• Load academia-2.als.
• Realism Conditions and Default Scopes:
• Model Under constrained.
• Examine various sample instances.
Code:
Code:
---------------- Signatures ----------------
abstract sig Person {}
sig Faculty extends Person {}
abstract sig Student extends Person {}
sig Graduate, Undergrad extends Student {}
sig Instructor in Person {}
sig Course {
taughtby: one Instructor,
enrolled: some Student,
waitlist: set Student}
fun teaches : Instructor -> Course { ~taughtby }