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

*From*: ALFREDO RUIZ <alruvanet@xxxxxxxxx>*Date*: Thu, 26 Oct 2023 09:35:05 -0700*References*: <c9b89fe7-8c0d-41dd-9d7a-d33b7b2287d8n@googlegroups.com> <B12DF474-2921-44E2-99F6-F6169D0461E5@gmail.com> <35a76524-49d1-41ae-afd7-52289c6ef2ccn@googlegroups.com>

Vaya al infierno

El jue, 26 oct 2023 9:29, 'Ashish Negi' via tlaplus <tlaplus@xxxxxxxxxxxxxxxx> escribió:

Thank you Stephan. This makes sense.--On Thursday, October 26, 2023 at 2:12:33 AM UTC-5 Stephan Merz wrote:Hello,writing a formal specification in a language such as TLA+ is different from writing a program. In particular, efficiency is (in principle) not a concern. From what I understand, you want to maintain a set of records such that when inserting a record, you overwrite any existing record with the same key. One way to define such an insert operation is(* Insert record rcd in set S but overwrite any existing record in S with the same key *)InsertWithUpdate(S, rcd) ==(S \ {r \in S : r.key = rcd.key}) \union {rcd}A similar operation can be defined on sequences, but it is a little more cumbersome and will have to be recursive.The easiest way to denote the function with the empty domain in TLA+ is to write << >>. Remember that sequences are functions, too.Hope this helps,StephanOn 25 Oct 2023, at 01:06, thisismy...@xxxxxxxxx <thisismy...@xxxxxxxxx> wrote:HiIn last few specs that i wrote, i naturally start with using set of records for variables like set of files. Then i hit the problem that i need to deduplicate these sets based on key field of record.e.g. for set: {[fileId: Nat, cleanupTime: Nat]}, when i insert {fileId:1, cleanupTime: 2} and {fileId:1, cleanupTime: 3}, i don't want to have 2 items in set but only one. I want set to look at `field` fileId as key for set.Is this possible ? From my search, i could not find this.Then i move to using sequences and writing AppendIfNotPresent(s, x) functions myself.I realized that since sequence is a function, can i create a function [fileId |-> record] ? and then updating same fileID can't insert 2 records.I believe someone already thought about this. What are cons of this approach ?About using function, I got stuck at initializing variables with an empty function in pluscal. How do I create an empty function ?ThanksAshish--

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+u...@xxxxxxxxxxxxxxxx.

To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/c9b89fe7-8c0d-41dd-9d7a-d33b7b2287d8n%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/35a76524-49d1-41ae-afd7-52289c6ef2ccn%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/CABpU1BkQTt-bXsQtqWCtrpNQPaf4LQGXneJy3wWC1_ZdNH%3DEMQ%40mail.gmail.com.

**References**:**[tlaplus] Set vs Functions for modelling***From:*thisismy...@xxxxxxxxx

**Re: [tlaplus] Set vs Functions for modelling***From:*Stephan Merz

**Re: [tlaplus] Set vs Functions for modelling***From:*'Ashish Negi' via tlaplus

- Prev by Date:
**Re: [tlaplus] Set vs Functions for modelling** - Next by Date:
**[tlaplus] How to explore states with all subset of a set ?** - Previous by thread:
**Re: [tlaplus] Set vs Functions for modelling** - Next by thread:
**[tlaplus] Why vars is defined as tuples instead of set** - Index(es):