Professional Documents
Culture Documents
Descriptive Notations: Logic-Based Specifications
Descriptive Notations: Logic-Based Specifications
Logic-based specifications
First-order logic
• First-order logic symbols:
– variables: x, y, z, …
– constants: 1, 2, John, Mary, …
– functions: +, -, age(p), …
– predicates: >, =, is_father(p1, p2), …
– connectors: Ù (and), Ú (or), ¬ (not), Þ (implies), Û (iff)
– quantifiers: $ (exists), " (for all)
• Examples of first-order formulas:
– x=2Ùy=1Þx>y
– is_father(John, Mary) Þ age(John) > age(Mary)
– " x, y (is_father(x, y) Þ age(x) > age(y))
Descriptive Notations: Logic 2
Case study (repeat)
– Each floor has two buttons (except the ground and the top
floors), one to request an up elevator and one to request a
down elevator. These buttons light up when pressed. The
lights switch off when the elevator visits the floor and is either
moving in the desired direction, or has no outstanding
requests. In the latter case, if both floor-request buttons are
pressed, only one is canceled. The algorithm to decide which
to service first should minimize the waiting time for both
requests.
stands for:
arrival(E, F, Ta) Ù
list(E, L, T, Ta) Ù
first(L) = F
Þ
stop(E, F, Ta)
stop(E, F, Ta) Ù
list(E, L, T, Ta + Dts) Ù
first(L) > F
Þ
departure(E, F, up, Ta + Dts)
stop(E, F, Ta) Ù
Tp > Ta+Dts Ù
list(E, empty, Ta+Dts, Tp) Ù
list(E, L, Tp, T) Ù
first(L) > F
Þ
departure (E, F, up, Tp)
departure(E, F, up, T)
Þ
arrival(E, F + 1, T + Dt)
stop(E, F, T)
Þ
standing(E, F, T, T + Dts)
request(E, F, TR) Ù
¬standing(E, F, Ta, TR) Ù
list(E, L, T, TR) Ù
LF = insert_in_order(L, F, E)
Þ
new_list(E, LF, TR )
abbreviation for
¬$T2Ln(…) Descriptive Notations: Logic 20
Verifying specifications
• The system can be simulated by providing a state (set
of facts) and using rules to make deductions
• Example:
stop(2, 3, 5)
standing(2, 3, 5, 7)
elevator 2 at floor 3 at least from instant 5 to 7
list(2, empty, 5, 7)
request(2, 8, 7)
Þ new_list(2, {8}, 7)
Þ (excluding other events)
departure(2, 3, up, 7)
arrival(2, 8, 7+Dt*(8-3))
Descriptive Notations: Logic 21
Verifying specifications
• Operational specifications
– Different languages: one to describe the system and one to
define its properties
– (mostly) fully mechanized
• Descriptive specifications
– The system and its properties are described in the same
language
– Proving properties, however, cannot be fully mechanized for
most languages