Artificial Intelligence: Foundations & Applications: Prof. Partha P. Chakrabarti & Arijit Mondal

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Artificial Intelligence: Foundations & Applications

Temporal Logic and Applications

Prof. Partha P. Chakrabarti & Arijit Mondal


Indian Institute of Technology Kharagpur

IIT Kharagpur 1
Introduction
• Specifying the system functionality requires notion of time
• Propositional logic cannot be applied directly

• Example
• b: brakes are pressed, a: accelerator is pressed, s: car stops, d: car slows down
• When brakes are pressed, the car slows down in the next instant
• When no accelerator is pressed then after a while the car continuously slows down
• When brakes are constantly kept pressed and there is no accelerator pressed, the car slows down and
eventually stops.

IIT Kharagpur 2
Verification of Combinational Circuits
a
a
sel Y1 sel Y2

b b

• Are Y1 and Y2 equivalent?


• Y1 = (a ∧ ¬sel) ∧ (b ∧ sel)
• Y2 = (a ∧ ¬sel) ∨ (b ∧ sel)
• Canonical structure of Binary Decision Diagram can be exploited to compare Boolean functions like Y1
& Y2

IIT Kharagpur 3
Verification of Sequential Circuits
r1 g1
RR
Arbiter
r2 g2

• Properties span across cycle boundaries


• Example: Two way round robin arbiter
• If the request bit r1 is true in a cycle then the grant bit g1 has to be true within the next two clock
cycles

IIT Kharagpur 4
Verification of Sequential Circuits
r1 g1
RR
Arbiter
r2 g2

• Properties span across cycle boundaries


• Example: Two way round robin arbiter
• If the request bit r1 is true in a cycle then the grant bit g1 has to be true within the next two clock
cycles
• Need temporal logic to specify the behavior

IIT Kharagpur 4
Verification of Sequential Circuits
r1 g1 r1(0) r1(1) r1(2)
RR r2(0) r2(1) r2(2)
Arbiter g1(0) g1(1) g1(2)
r2 g2 g2(0) g2(1) g2(2)
T=0 T=1 T=2

• If the request bit r1 is true in a cycle then the grant bit g1 has to be true within the next two clock cycles
• [t[r1(t) → g1(t + 1) ∨ g1(t + 2)]
• In propositional temporal logic time (t) is implicit
• always r1 → (next g1) ∨ (next next g1)

IIT Kharagpur 5
Temporal logic
• The truth value of a temporal logic is defined with respect to a model.
• Temporal logic formula is not statically true or false in a model.
• The models of temporal logic contain several states and a formula can be true in some states and false
in others.
• Example:
• I am always happy.
• I will eventually be happy.
• I will be happy until I do something wrong.
• I am happy.

IIT Kharagpur 6
Kripke Structure
p p,q r
S0 S1 S2
100 110 001

S3 S4
010 011
q q,r

• M = (AP, S, S0, T, L)
• AP – Set of atomic proposition
• S – Set of states
• S0 – Set of initial states
• T – Total transition relation (T ⊆ S × S)
• L – Labeling function (S → 2AP )

IIT Kharagpur 7
Path
• A path π = s0, s1 , . . . in a Kripke structure is a sequence of states such that [i, (si , si+1 ) ∈ T
• Sample paths
• S0, S1, S2, S4, S1, . . .
• S0, S3, S4, S0, . . .
• S0, S1, S4, S1, . . . p p,q r
• π = s0, s1 , . . . , sk , sk+1 . . .
| {z } S0 S1 S2
prefix of πk in π 100 110 001
• π= s0, s1 , . . . , sk , sk+1
...
| {z }
suffix of π k in π S3 S4
010 011
q q,r

IIT Kharagpur 8
Temporal operators
• Two fundamental path operators
• Next operator
• Xp – property p holds in the next state
• Until operator
• p U q – property p holds in all states upto the state where property q holds
• Derived operators
• Eventual/Future operator
• Fp – property p holds eventually (in some future states)
• Always/Globally operator
• Gp – property p holds always (at all states)
• All these operators are interpreted over the paths in Kripke structure under consideration
• All Boolean operators are supported by the temporal logics

IIT Kharagpur 9
The next operator (X)
Xp

p holds

• p holds in the next state of the path

• Formally
• π |= Xp iff π 1 |= p

IIT Kharagpur 10
The until operator (U)
pUq

p holds q holds

• q holds eventually and p holds until q holds

• Formally
• π |= p U q iff \k such that π k |= q and [j, 0 ≤ j < k we have π j |= p

IIT Kharagpur 11
The eventual operator (F)
Fp

p holds

• p holds eventually (in future)

• Formally
• π |= Fp iff \k such that π k |= p
• This can be written as true U p

IIT Kharagpur 12
The always operator (G)
Gp
p holds

• p holds always (globally)

• Formally
• π |= Gp iff [k we have π k |= p
• This can be written as ¬(true U ¬p) or ¬F¬p

IIT Kharagpur 13
Branching Time Logic
• Interpreted over computation tree

a,b

a,b b,c c

b,c c a,b c c

IIT Kharagpur 14
Path Quantifier
• A: “For all paths ...”

• E: “There exists a path ...”

IIT Kharagpur 15
Universal Path Quantification

AX p AG p p

p p p p

p p p p

In all the next states p holds. Along all the paths p holds
forever.

IIT Kharagpur 16
Universal Path Quantification

AF p A(pUq) p

p p q

p p q q

Along all the paths p holds Along all the paths p holds
eventually. until q holds.

IIT Kharagpur 17
Existential Path Quantification

EX p EG p p

p p

There exists a next state there exists a path along


where p holds. which p holds forever.

IIT Kharagpur 18
Existential Path Quantification

EF p E(pUq) p

p q

There exists a path along There exists a path along


which p holds eventually. which p holds until q holds.

IIT Kharagpur 19
Duality between Always & Eventual operators
• Gp = p ∧ (next p) ∧ (next next p) ∧ (next next next p) . . .
= ¬(¬(p ∧ (next p) ∧ (next next p) ∧ (next next next p) ∧ . . .))
applying De Morgan’s law
= ¬(¬p ∨ (next ¬p) ∨ (next next ¬p) ∨ (next next next ¬p) ∨ . . .)
= ¬(F¬p)

• Therefore we have
• Gp = ¬F¬p
• Fp = ¬G¬p

IIT Kharagpur 20
Computation Tree Logic (CTL)
• Syntax:
• Given a set of Atomic Propositions (AP):
• All Boolean formulas of over AP are CTL properties
• If f and g are CTL properties then so are ¬f, AXf, A(f U g), EXf and E(f U g),
• Properties like AFp, AGp, EGp, EFp can be derived from the above

• Semantics:
• The property Af is true at a state s of the Kripke structure iff the path property f holds on all paths
starting from s
• The property Ef is true at a state s of the Kripke structure iff the path property f holds on some path
starting from s

IIT Kharagpur 21
Nested properties in CTL

• AX AGp
• From all the next state p holds forever along all paths
• EX EFp
• There exist a next state from where there exist a path to a state where p holds
• AG EFp
• From any state there exist a path to a state where p holds

p p p

p p p p p p p p p
AX AGp EX EFp AG EFp
IIT Kharagpur 22
Than« y¯µ!

IIT Kharagpur 23

You might also like