VS Code中vscode-tlaplus插件配置TLA+ CONSTANTS报错问题咨询
=? Short Answer
This is expected behavior from TLC's configuration parser. The key difference between = and <- in constant assignments lies in what kind of values they accept.
Detailed Explanation
Let’s break down why your initial config failed, and why your workaround (and a simpler alternative) works:
Why the first config threw an error
When using=in a TLC config to assign a constant, the right-hand side must be a literal value—think numbers, strings, or explicitly enumerated sets like{1,2,3,4}. The expression1..4is a TLA+ range shorthand, not a literal, so TLC’s parser doesn’t recognize it as a valid value for the=operator. That’s why you got theConfigFileExceptioncomplaining about missing=or<-.Why your workaround works
The<-operator in TLC configs is designed to bind constants to any valid TLA+ expression, including ranges, functions, or aliases defined in your module. By definingConstSizeRange == 1..4in your.tlafile and then writingSizeRange <- ConstSizeRange, you’re telling TLC to evaluate that expression and assign its result to theSizeRangeconstant.A simpler fix (no extra module constants needed)
You don’t actually need to defineConstSizeRangeorConstValueRangein your module at all. You can directly bind the range expression to the constant in the config using<-:SPECIFICATION Spec CONSTANTS SizeRange <- 1..4 ValueRange <- 0..3 Capacity = 7 Items = {"a", "b", "c"}This keeps your module clean while still assigning the correct range values.
Why your module's CONSTANT definitions still matter
Your concern that "CONSTANT definitions lose meaning" is unfounded—those abstract constants are a core part of TLA+'s design:
- They make your specification generic, so you can test different range values (like
1..5or2..6) without modifying the module itself. - The config’s
<-is just instantiating that abstract parameter with a concrete expression, which is exactly how TLA+ is meant to be used: write abstract specs, then instantiate them with concrete values for model checking.
Key Takeaway
- Use
=for literal values (e.g.,Capacity = 7,Items = {"a","b","c"}). - Use
<-for any TLA+ expression (e.g., ranges, functions, references to module-defined expressions).
内容的提问来源于stack exchange,提问作者Nicholas

