[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlaplus] Verifying concurrent data structures



Here's how I approach this:
  1. Write a spec for the abstract datatype (e.g. set) and then show that your implementation refines it.
  2. Your spec for the abstract datatype should model the client in addition to the data structure. For a single-threaded data structure, clients serialize their calls; for a concurrent data structure, they do not.
A while back I did this for a concurrent bloom filter I wrote, which is a perfect example since you asked about concurrent sets.

Here's the spec for the abstract datatype:
https://github.com/Calvin-L/calbloom/blob/main/design/ConcurrentSet.tla

The three variables "pc", "values_to_insert" and "output" model the clients. Each client first picks a value to insert into the set (PickValue) then hands off control to the data structure to do the actual insert (DoInsert). The data structure returns output to the client in the "output" variable. Since inserts are modeled as a single action, this spec says that inserts should appear to happen atomically.

Here's the spec for the implementation:
https://github.com/Calvin-L/calbloom/blob/main/design/ConcurrentBloomFilter.tla

There's a wrinkle here: since the bloom filter doesn't store the set explicitly, it's not possible to write a refinement mapping. So instead, my implementation refines a different form of the set specification that only includes the log of inputs/outputs that clients observe. I maintain that this form is equivalent to the simpler form in my first link, although I haven't proven it.

On Tue, Dec 21, 2021 at 3:29 PM Jones Martins <jonesmvc@xxxxxxxxx> wrote:
Hello, everyone

Since TLA+ can also verify (and prove) correctness of algorithms, protocols, etc., I wonder how to verify data structures. When modelling a sequential data structure compared to a concurrent data structure, how should one go about specifying it?

 For example, let's say I implemented an abstract Set specification with "Add", "Remove" and "Contains" actions. How do I prove correctness? What about a concurrent Set?

Thanks

Jones

--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/667639f2-93b3-4d8d-b99f-e99dec4cbae5n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/CABf5HMjirbyPxxEy2seNoGH1jKCv82rEX-8qVmFCcC2sj2Cn2g%40mail.gmail.com.