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

Alloy Modeling for Academic Courses

Formal Method 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)
11 views8 pages

Alloy Modeling for Academic Courses

Formal Method 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: Syed Ali Farhad
Roll No: 38
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

Checking assertions like 'NoWaitingTeacher' and 'NoEnrolledAndWaiting' is crucial as it validates model integrity by ensuring no logic violations occur, such as a teacher waiting for their own course or students being enrolled and on the waitlist simultaneously. These checks prevent potential inconsistencies and logical fallacies within the designed system .

'Signatures' define the hierarchical structure and types of entities in the academic model, like Person, Faculty, and Course. 'Facts' establish relationships and constraints that these entities must follow, such as all instructors being Faculty or Graduate students. Together, these components create a robust framework that enforces logical consistency and constraints throughout the model .

The model ensures real-world role reflection by defining specific realism constraints, such as having a graduate student who is also an instructor and setting a minimum number of courses and students. These conditions mirror actual academic environments where graduate students often take on dual roles, institutionalizing such dynamics within the model logic .

The model ensures uniqueness among students by stipulating that no two distinct students can have the same ID. This is enforced through the fact clause stating all s1, s2: Student | s1 != s2 => s1.id != s2.id .

Default scopes in the academic model define the constraints within which elements like courses and students operate, ensuring the model's abstraction reflects realistic data sizes and conditions. These scopes contribute to model accuracy by limiting constructs to reasonable sizes that reflect expected real-world scenarios, preventing overgeneralization or under-specification .

The model prevents cyclic dependencies by requiring that no course is cyclically linked in its prerequisite chain. This is articulated in the constraint that no course should be part of its own transitive prerequisite closure, expressed as all c: Course | c !in c.^prerequisites .

The concept of realism in the model is incorporated by requiring the existence of a graduate student who is also an instructor. This is one of the realism constraints defined in the model, ensuring that such positions exist to reflect real-world academic settings .

The model ensures students on a waitlist have met prerequisites by asserting that all waitlisted students must have their requisite courses within their transcripts. This significance lies in maintaining academic standards and fair process for course enrollment, upholding the integrity of academic progression requirements .

The model places the constraint that all instructors must either be Faculty or Graduate students, ensuring a structured hierarchy. Additionally, no instructor can be on the waitlist for a course they teach, preventing conflicts of interest or misuse of the waitlist privilege .

The model handles such instances by ensuring the uniqueness of student IDs rather than regulating transcription sets directly. While identical transcripts might occur, the model relies on the unique identification infrastructure to differentiate students, which indirectly prevents issues from duplicate transcription contexts alone .

You might also like