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

*From*: Stephan Merz <stephan.merz@xxxxxxxxx>*Date*: Sat, 14 Nov 2020 12:32:31 +0100*References*: <09339bc6-eea4-4480-a6ee-75567f92bb4an@googlegroups.com> <58556ffe-17ae-81f0-6c06-9261d4a85225@lemmster.de> <7039e237-bf47-4c72-9941-6edd25188ee8n@googlegroups.com> <a9b78c6b-b5ae-a8af-f281-d95cfd586c1f@lemmster.de> <14047959-eaa6-4691-995d-4d6aa27cbec5n@googlegroups.com>

Hello, apologies for the late reply – I tried to reconstruct your spec from what you pasted in the message but it may be a bit out of sync with the spec you are actually working on. The first issue that I noticed was that your invariant mentions both constants MaxBufferLen and MaxTotalNumberOfItemsProduced but you only have an assumption for the first constant. So I added the conjunct /\ MaxTotalNumberOfItemsProduced \in Nat to your constant assumption. Also, that assumption must of course be used in the proof but this is not shown in the proof that you reported being able to finish. Note that TLC will not help find you problems involving missing assumptions about constants because constants have fixed values in your model. The second issue concerns the Consume action: it increments the variable num_of_items_consumed while leaving num_of_items_produced unchanged. Therefore you will not be able to conclude that the inequality num_of_items_consumed <= num_of_items_produced (which is your SafetyProperty) is preserved. This should have been discovered when you used TLC to check if your invariant was inductive. A minute of reflection indicates that the invariant that you really need is num_of_items_consumed + Len(buffer) <= num_of_items_produced Now we can start the formal proof of the invariant, based on the general schema for invariant proofs. The only non-obvious step is the one that shows that [Next]_vars preserves the invariant, so I used the "decompose proof" command to split it into individual proof steps corresponding to the sub-actions of [Next]_vars. The cases corresponding to Produce and UNCHANGED vars are again simple, leaving us with the Consume action, which unfortunately isn't proved automatically. I now guessed that the prover needed to know that the length of the buffer decreases in this step and therefore asserted <3>. Len(buffer') = Len(buffer)-1 With this knowledge, the prover indeed managed to prove the step corresponding to the Consume action. (I could have split the conclusion IInv' into its individual conjuncts to find out which ones go through and which ones don't, further narrowing down the source of the problem.) For proving the auxiliary level-3 step, I use the lemma HeadTailProperties from the library module SequenceTheorems. (These modules are by default installed in /usr/local/lib/tlaps/, just like TLAPS.tla, it is worth looking at the theorems they provide if you are doing any non-trivial proof. You may also look at the proofs of these lemmas in SequenceTheorems_proofs.tla if you are stuck in some proof about sequences.) The overall module with the full proof is attached. Hope this helps, Stephan P.S.: In a first approximation, you should not have to care about which backend (SMT, Zenon or Isabelle) proves any given step since TLAPS will call all of them. Adding "BY SMT" etc. to a step simply documents which backend succeeds in proving a step and avoids unnecessary calls to the other backends. -s 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/9BDED377-1BA4-4A2F-944B-E58D3D2D1A26%40gmail.com. |

**Attachment:
producer_consumer.tla**

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/9BDED377-1BA4-4A2F-944B-E58D3D2D1A26%40gmail.com. |

**Follow-Ups**:

**References**:**[tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS***From:*Smruti Padhy

**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS***From:*Markus Kuppe

**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS***From:*Smruti Padhy

**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS***From:*Markus Kuppe

**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS***From:*Smruti Padhy

- Prev by Date:
**Re: [tlaplus] Proving inductive predicates in TLAPS** - Next by Date:
**[tlaplus] Use of labels in PlusCal** - Previous by thread:
**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS** - Next by thread:
**Re: [tlaplus] Finding Inductive Invariants using TLC and Proving it using TLAPS** - Index(es):