67 Assignment 2 AIDS2405
67 Assignment 2 AIDS2405
1. Answer the following questions based on the concepts of temporal logic discussed in the
lecture.
2. Provide clear explanations, examples, and diagrams where applicable.
3. Submit your answers in a Word document or PDF.
ANS:
Definition: Temporal logic is a sophisticated system for reasoning about statements that involve
time. It extends traditional logic by adding a temporal dimension, allowing us to describe not
just whether something is true or false, but precisely when it holds true. Think of it as adding
time awareness to logical statements - instead of just saying "the light is red," we can express
complex temporal relationships like "the light is red now," "the light will be red in the future," or
"the light remains red until it turns green."
Significance in Computer Science: The importance of temporal logic in computer science cannot
be overstated:
a) System Verification:
• Enables formal verification of software systems by checking if they behave correctly over
time
• Helps detect potential deadlocks and race conditions in concurrent systems
• Ensures safety-critical systems maintain required properties throughout their execution
b) AI and Robotics:
c) Real-world Applications:
• Smart Home Systems: Managing automated responses (e.g., "if motion is detected, then
lights should turn on within 2 seconds")
• Traffic Management: Coordinating traffic signals and flow patterns
• Industrial Control: Monitoring and controlling manufacturing processes
• Medical Systems: Managing patient monitoring and drug delivery systems
• Basic: ◯AC_ON ("The air conditioning will turn on in the next minute")
• Complex: ◯(TEMP < 75) ("In the next state, temperature will be below 75 degrees")
Real-world application:
In a manufacturing system:
◯ASSEMBLY_START ("The assembly process will begin in the next step")
◯(ROBOT_ARM_POSITION = HOME) ("The robot arm will return to home position
next")
2. Eventually Operator (◊): Definition: Indicates that something must become true at some
future point Examples:
Copy
In a delivery system:
◊PACKAGE_DELIVERED ("The package will eventually be delivered")
◊(TRUCK_RETURNS_TO_DEPOT) ("The delivery truck will eventually return to the
depot")
3. Always Operator (□): Definition: Specifies that something must remain true in all future
states Examples:
• Basic: □DOOR_CLOSED ("The door will remain closed at all times during the night")
• Complex: □(TEMP < 100) ("Temperature always stays below 100 degrees") Real-world
application:
Copy
In a security system:
□(UNAUTHORIZED_ACCESS → ALARM) ("Always: if unauthorized access is detected,
alarm is triggered")
□(CAMERA_ACTIVE) ("Security cameras remain active at all times")
4. Until Operator (U): Definition: First condition holds true continuously until the second
condition becomes true Examples:
• Basic: OPERATE U ERROR ("The system will operate until an error occurs")
• Complex: (HEATING U TEMP > 350) ("Heating continues until temperature exceeds
350 degrees") Real-world application:
Copy
In a backup system:
(BACKUP_IN_PROGRESS U BACKUP_COMPLETE) ("Backup continues until completion")
(RETRY U SUCCESS) ("System keeps retrying until success is achieved")
ANS:
Detailed Components:
a) States (S):
Copy
S1: {temp: 70, fan: off, humidity: 45}
S2: {temp: 75, fan: on, humidity: 48}
S3: {temp: 72, fan: on, humidity: 46}
Copy
R = {
(S1 → S2): Temperature rise triggers fan
(S2 → S3): Fan operation reduces temperature
(S3 → S1): System returns to initial state
}
Copy
L(S1) = {"Idle", "Normal_Temp"}
L(S2) = {"Running", "High_Temp"}
L(S3) = {"Running", "Normal_Temp"}
Copy
States: S1, S2, S3
Transitions: S1→S2→S3→S1
Labeling:
L(S1) = {"Idle"}
L(S2) = {"Running"}
L(S3) = {"Completed"}
Detailed Evaluation:
• TRUE
• Reasoning:
1. We start in S1
2. The next state is S2 (following transition relation)
3. L(S2) contains "Running"
4. Therefore, "Running" is true in the next state
• TRUE
• Detailed reasoning:
1. Start in S1: "Idle" is true (in L(S1))
2. Move to S2: Need to reach "Completed"
3. Move to S3: "Completed" becomes true
4. The path maintains required conditions:
▪ "Idle" is true in S1
▪ We reach "Completed" in S3
▪ The sequence satisfies Until operator requirements
• Explain the semantics of the "Until" (U) and "Release" (R) operators.
• Create a timeline diagram illustrating how each operator works over different states.
ANS:
Linear Time:
Copy
1. Assembly Line Operations:
- Fixed sequence of manufacturing steps
- Predetermined quality checks
- Specific timing requirements
Branching Time:
Example Applications:
Copy
1. Game AI Decision Making:
State1 (Start)
├── Path A: Attack
│ ├── Win
│ └── Lose
└── Path B: Defend
├── Counter-attack
└── Retreat
2. Network Routing:
Router_State
├── Path1: Low latency, high cost
├── Path2: Medium latency, medium cost
└── Path3: High latency, low cost
• Detailed Definition: p U q means p must hold continuously until q becomes true, and q
must eventually become true
• Formal Semantics:
o p must be true in all states before q
o q must become true at some point
o The truth of p U q at state s requires:
1. q becomes true at some future state
2. p remains true in all states between s and when q becomes true
Example Timeline:
Copy
Time: t0 t1 t2 t3 t4 t5
p p p q - -
(p U q) is true at t0 because p holds until q occurs at t3
• Detailed Definition: p R q means q must hold until and including the first state where p
becomes true (if p ever becomes true)
• Formal Semantics:
o If p never becomes true, q must hold forever
o q must hold in all states up to and including the first state where p holds
o Less stringent than Until as p is not required to eventually occur
Example Timeline:
Copy
Time: t0 t1 t2 t3 t4 t5
q q p,q - - -
(p R q) is true at t0 because q holds until p becomes true at t2
ANS:
Problem Description:
Copy
A home security system that needs to:
- Monitor entry points continuously
- Respond to unauthorized access within 3 seconds
- Maintain system status logging
- Handle multiple sensor inputs
- Manage alarm states
Copy
1. Continuous Monitoring:
□(SENSORS_ACTIVE)
"Always: sensors are active"
2. Response Time:
□(UNAUTHORIZED_ACCESS → ◯◯◯ALARM_ON)
"Always: if unauthorized access detected, alarm activates within 3 time
steps"
3. System Status:
□(SYSTEM_ERROR → ◊NOTIFICATION_SENT)
"Always: if system error occurs, eventually notification is sent"
4. Sensor Integration:
□((MOTION_DETECTED ∧ DOOR_OPEN) → ◯CAMERA_ACTIVATE)
"Always: if motion detected and door open, then activate camera in next
state"
System Design:
Copy
States:
S1 ("Startup"): Initial system boot
S2 ("Operating"): Normal operation
S3 ("Shutdown"): System shutdown
Transitions:
R = {
(S1 → S2): Startup completed
(S2 → S2): Continued operation
(S2 → S3): Shutdown initiated
(S3 → S1): System restart
}
Labeling Function:
L(S1) = {"Initializing", "Power_On"}
L(S2) = {"Running", "Active"}
L(S3) = {"Shutdown", "Power_Off"}
Copy
1. Start at S1 ("Startup")
2. Follow possible paths:
S1 → S2 → S3
3. Analysis:
- "Shutdown" ∈ L(S3)
- Path exists: S1 → S2 → S3
Therefore, ⋄"Shutdown" is TRUE at S1
Steps:
Copy
1. Root: ⋄"Complete"∧□"Running"
2. Decomposition:
├── ⋄"Complete"
└── □"Running"
3. Branch Development:
├── State1: Running=True
│ └── State2: Complete=True, Running=True
└── State1: Running=True
└── State2: Running=True
4. Result: Satisfiable with minimum two states where:
- "Running" holds in all states
- "Complete" becomes true in at least one state
The tableaux method shows that we can construct a model where both conditions are met,
proving satisfiability.