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

*From*: Stephan Merz <stephan.merz@xxxxxxxxx>*Date*: Thu, 15 Dec 2022 09:00:27 +0100*References*: <6c72f651-82f0-416c-b01f-744a7bef5662n@googlegroups.com>

Hello, please check Section 16.1.10 of Specifying Systems, which discusses strings and characters and even contains a function to convert lower-case letters to ASCII. In short, TLA+ has no hardwired definition of what characters are. In your representation, the variables in_pattern and in_text are sequences of strings, not characters. As far as I can tell, the algorithm is independent of any concrete representation of characters. I suggest that you make the set of characters as well as the inputs to the algorithm parameters of your specification, i.e. introduce (at the top of the module) CONSTANT Character, text, pattern ASSUME text \in Seq(Character) /\ pattern \in Seq(Character) When you use TLC to check your algorithm, you can instantiate these constants by concrete values, e.g. Character <- {a,b,c} \* a set of model values text <- << a, a, b, a, c >> pattern <- << b, a >> In this way, you'll also alleviate the effect of state explosion. If you want to go further than testing the algorithm on concrete inputs, you can replace the parameters `text' and `pattern' by variables and nondeterministically assign them finite (bounded-length) sequences of characters by writing something like define { \* sequences of characters of length at most n CharSeq(n) == UNION { [1 .. k -> Character] : k \in 0 .. n } } [...] variables text \in CharSeq(5), pattern \in CharSeq(3); [...] In this way, TLC will check the algorithm for all text / pattern strings of bounded length. Remember that TLA+ is a language for specifying algorithms at a high level of abstraction, not a programming language. Hope this helps, Stephan
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/ECAA9F9A-1BE6-4CB9-A832-56E384F2A9D8%40gmail.com. |

**Follow-Ups**:**Re: [tlaplus] Functions in the standard libraries***From:*mohan radhakrishnan

**References**:**[tlaplus] Functions in the standard libraries***From:*mohan radhakrishnan

- Prev by Date:
**[tlaplus] Functions in the standard libraries** - Next by Date:
**Re: [tlaplus] Functions in the standard libraries** - Previous by thread:
**[tlaplus] Functions in the standard libraries** - Next by thread:
**Re: [tlaplus] Functions in the standard libraries** - Index(es):