views:

64

answers:

2

I'm not sure this is appropriate for stackoverflow, but I don't know where else to ask. I'm studying the B-Method for proving consistence in requirement specifications, and I have an issue with the logic math notation when specifying the pre conditions of the operations.

Simplifying the original problem, I have a variable which is a subset flights of the cartesian product between FLIGHT_NO x TIME x TIME, where for each member (no,td,ta), no means the number of the flight, td the time of departure and ta the tme of arrival. How can I get, using math logic notation, the element of flights that has the biggest value of td?

+3  A: 

Do you want to get such an element, or to test that an element you have satisfies this property? I am asking because the second seems a sensible precondition to an operation. I don't know the B-Method specifically; I've looked at some documents, but can't find a quick reference, so this may be wrong in some details.

The second should look like this (prj2 is used for the second projection):

HasGreatestTd(flight) = flight \in flights \and \forall flight' (flight' \in flights => prj2(flight) >= prj2(flight'))

Then the first is:

flightWithGreatestTd = choice({flight | HasGreatestTd(flight)})
Alexey Romanov
Well, I came up with a solution that looks like your answers. But I can't find a projection feature in AMN which, since in the actual problem flights is a subset of the powerset of the cartesian product of eight sets (and not three), it's making it very hard to write...
webdreamer
I've found projection in the software I'm using (Atelier B), but it's only for relations. Should I make prj2(prj2(prj2 flights) if I want to access the 4th field of flights for example? Does it work like lists in lisp? There should be some simpler way to do this xD I may take a look into arrays
webdreamer
Actually, I think you should look into using records rather than arrays.
Alexey Romanov
I could, but I've never heard of records in the context of AMN.
webdreamer
I thought I saw them mentioned, but I can't find it now.
Alexey Romanov
+1  A: 

Forgive my ignorance, I'm not familiar with the B-Method. But couldn't you use the uniqueness quantifier? It'd look something like:

there exists a time td such that for all times td', td > td'

and

for all td, td', td'', if td > td'' and td' > td'' then td == td'

This, of course, assumes that there is exactly one element in the set. I can't really tell if the B-Method allows for the full power of first order logic but I assume you could come close to this.

Farley Knight
Note that you aren't even mentioning the `flights` variable.
Alexey Romanov
Yeah, an easily correctable mistake, but still a mistake. We posted around the same time and when I saw yours I upvoted it since it's probably better than mine.
Farley Knight