0% found this document useful (0 votes)
15 views8 pages

Formal Methods Assignment Overview

Formal Method detailed Assignment

Uploaded by

9qnqghw66p
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)
15 views8 pages

Formal Methods Assignment Overview

Formal Method detailed Assignment

Uploaded by

9qnqghw66p
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

Assignment no 3

Submitted By:
Name: Moneeb Mushtaq
Roll No: 07
Subject: Formal Method
Department: BS-SE 5th
Session: 2021-2025

Submitted to: Khurram Mustafa

Due Date: 06-03-2024

University Of Kotli AJ&K


1. Exercise No 1

• Load [Link].
• 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 [Link] => some [Link]
-- Graduate students do not teach courses they are enrolled in
-- or waiting to enroll in
all c: Course | [Link] !in [Link] + [Link]
}
-- Realism Constraints
pred RealismConstraints [] {
-- There is a graduate student who is an instructor
some Graduate & Instructor
-- There are at least two courses
#Course >= 2

-- There are at least three undergraduates


#Undergrad > 2}
run RealismConstraints -- for 4

-- Assertions
assert NoWaitingTeacher {
all c: Course | no ([Link] & [Link])}
check NoWaitingTeacher for 10
assert NoEnrolledAndWaiting {
all c: Course | no ([Link] & [Link])}
check NoEnrolledAndWaiting for 10

2. Exercise 2
• Load [Link].
• Realism Conditions and Default Scopes:
• Model Under constrained.
• Examine various sample instances.
Code:

---------------- Signatures ----------------


abstract sig Person {}
sig Faculty extends Person {}
abstract sig Student extends Person {
id: one Id,
transcript: set Course}
sig Graduate, Undergrad extends Student {}
sig Instructor in Person {}
sig Course {
taughtby: one Instructor,
enrolled: some Student,
waitlist: set Student,
prerequisites: set Course}
sig Id {}
---------------- 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 [Link] => some [Link]
-- Graduate students do not teach courses they are enrolled in
-- or wainting to enroll in
all c: Course | [Link] !in [Link] + [Link]
-- No student is enrolled and on the waitlist for the same course
all c: Course | no ([Link] & [Link])
-- No two distinct students have the same ID
all s1, s2: Student | s1 != s2 => [Link] != [Link]
-- A student can only have a course for which they have the prerequisites
all s: Student | [Link] in [Link]
-- There are no cycles in the prerequisite dependencies
all c: Course | c !in c.^prerequisites}
------------------- Run ---------------------
pred RealismConstraints [] {
-- There is a graduate student who is an instructor
some Graduate & Instructor
-- There are at least two courses
#Course >= 2
-- There are at least three undergraduates
#Undergrad > 2}
run RealismConstraints for 4
---------------- Assertion ----------------
-- No instructor is on the waitlist for a course that he/she teaches
assert NoWaitingTeacher {
all c: Course | no ([Link] & [Link])}
check NoWaitingTeacher for 10
-- A student can only wait to be in a course for which they have the prerequisites
assert AllWaitsHavePrereqs {
all s: Student | (waitlist.s).prerequisites in [Link]}
check AllWaitsHavePrereqs

3. The executed code and the instance created in alloy family 3.


• Load [Link]
• Realism Conditions and Default Scopes
• Manipulating Scopes:
• Additional Questions:

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 }

---------------- 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 [Link] => some [Link]

-- Graduate students do not teach courses they are enrolled in


-- or wainting to enroll in
all c: Course | [Link] !in [Link] + [Link]}

------------------- Run ---------------------


pred RealismConstraints [] {
-- There is a graduate student who is an instructor
some Graduate & Instructor
-- There are at least two courses
#Course >= 2
-- There are at least three undergraduates
#Undergrad > 2}
run RealismConstraints for 4

---------------- Assertion ----------------


-- Note: to check the assertion below you must comment the run command
-- above first (similarly for the second check)
-- No instructor is on the waitlist for a course that he/she teaches
assert NoWaitingTeacher {
all c: Course | no ([Link] & [Link])
}-- check NoWaitingTeacher for 10

-- No student is enrolled and on the waitlist for the same course


fact NoEnrolledAndWaiting {
all c: Course | no ([Link] & [Link])}
-- check NoEnrolledAndWaiting for 10

Common questions

Powered by AI

The academic model enforces that students can only be waitlisted if someone is already enrolled in the course and that they have the prerequisites . Enforcing these conditions is critical to ensuring fair and logical resource allocation and maintaining an organized, efficient course registration process. This prevents students from being inappropriately waitlisted for courses they are not qualified to enroll in, which could otherwise lead to inefficiencies and confusion in managing course membership .

Eliminating cycles in prerequisite dependencies is crucial because it prevents logical paradoxes and infeasible course progressions where fulfilling prerequisites becomes impossible . In educational contexts, such cycles would create deadlock situations where students could not satisfy the required prerequisites for progression, thereby ensuring that course dependencies are acyclic maintains logical consistency and planning feasibility within academic programs.

Default scopes in Alloy define the maximum size of each signature and enforce limitations that assist in checking assertions systematically . By setting scopes, the verification process can assert conditions like "NoWaitingTeacher" or "NoEnrolledAndWaiting" over finite model instances, confirming the model's accuracy within feasible bounds . This aids in managing computational complexity and improving efficiency during verification.

Including constraints to have at least two courses and three undergraduates ensures diversity and a basic infrastructure for an academic model . It sets a foundation for multiple interactions and dependencies among entities, reflecting a more realistic academic environment where various courses and a minimum number of students are essential for academic operations to function and validate different scenarios and assertions effectively.

The Alloy model constrains graduate students by preventing them from teaching any course they are enrolled in or waitlisted for . This ensures that there are no overlaps of roles that could lead to conflicts of interest or issues in managing dual responsibilities, thereby maintaining clear separations of duties within the academic structure.

Requiring that no two distinct students share the same ID ensures each student's uniqueness within the model, paralleling real-world scenarios where unique identifiers are critical for reliable student identification and data management . This constraint helps prevent potential issues with misidentification, ensuring the persistence and integrity of associated student data across various functions like course enrollment and transcript management.

The realism constraints ensure role assignments' integrity by imposing conditions such as requiring that all instructors must be either Faculty or Graduate Students, ensuring no graduate student teaches a course they are enrolled or waitlisted in, and verifying that instructors in multi-roles (e.g., Graduate and Instructor) are modeled correctly . This maintains the logical separation of responsibilities and roles within the model, preventing mismatches and potential conflicts in the academic setup.

Realism constraints support generating valid sample instances by imposing conditions that reflect realistic scenarios, such as having at least two courses, ensuring instructor categorization, and avoiding cycles in prerequisites . These constraints provide a framework that models must adhere to, enabling the production of meaningful and operationally coherent instances that respect logical and operational boundaries of academic settings, thereby aiding in thorough analysis and validation of model behavior.

Ensuring that students' transcript prerequisites are a subset of their transcript is essential for validating that students meet all necessary conditions before advancing in their study program . It guarantees that students cannot be allowed to take courses unless they have already satisfied previous course requirements, maintaining educational standards and integrity by preventing students from bypassing essential learning steps.

Failing to verify this assertion could lead to logical inconsistencies where instructors might simultaneously teach and be waitlisted for the same course, which defies logical academic operations . This oversight might allow conflicts of role performance, resource allocation issues, and could undermine the integrity of the model by permitting contradictory scenarios, thus compromising the validity of the educational system it represents.

You might also like