You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
(Low Priority) Basic type and size checks in the grammar #6
Redux had to hand-write basic checks that the grammar should express. ReduxISU/Redux#624 added "must be a non-empty set of integers" to Partition and "needs three groups" to 3-Dimensional Matching. If SPADE checked these, every problem would get them consistently.
Already works
S subset int checks that every element is an integer: {1,2,x} is rejected.
Wanted
Type checks: integer, number, boolean (True/False/T/F) and identifier.
Non-empty: today {} passes S subset int.
Size: e.g. "exactly three groups" or "pairs of length 2". UtilCollection has assertCount, but the grammar can't use it.
A single value: a way to say a field is a plain value rather than a collection.
The existing is int and is set constraints should be fixed first, since they don't check what they claim (#10).
changed the title [-]Basic type and size checks in the grammar (Nice to Have)[/-][+](Low Priority) Basic type and size checks in the grammar[/+]on Oct 1, 2026
A proposal for this issue, for feedback before any code is written. It builds on #15 (is int / is set / is list now check their type) and #17 (is multiset).
These work like int today: x is T checks one value, and S subset T checks every element.
Type
Accepts
Rejects
number
3, -2, 1.5, 0.25
1,5, 1e3, abc
bool
True, False, T, F, in any letter case
yes, 1
identifier
a letter or _, then letters, digits or _: x1, node_3
3x, New York
string
any single value
a set or list
string matches how Redux already writes DFA and NFA grammars (S is string, I is string). Today those parts are parsed but never checked (#14).
number uses a fixed format (digits, an optional sign and an optional decimal point) that doesn't change with the computer's language settings, so 1,5 is never read as one and a half.
2. Non-empty and size
{N | N is multiset, N subset int, N is nonempty}
{(X,Y,Z,M) | X is set, Y is set, Z is set, size M >= 1}
{(S,K) | S is set, K is int, size S <= K}
N is nonempty: at least one element. This is the common case, so it gets its own keyword.
size N <op> n, with <op> one of =, <, <=, >, >=, and n either a number or another integer field of the same instance (as in size S <= K).
Failure messages follow the existing style: Constraint size S <= K failed: S has 5 elements, K is 3.
Grammar changes
number, bool, identifier and string join int as built-in sets (lexer).
nonempty joins set, list and multiset as is keywords (lexer).
A new constraint form 'size' TERM COMPARE (TERM | number) (parser).
describe certificate sizes inside the grammar where both sizes are in the same instance.
Comparing a certificate's size with the instance's K still happens in Redux, because they're parsed separately.
Open questions
Keywords: nonempty and size? Or the set-builder style |S| <= K? That reads like the math, but | already separates the format from the constraints, which could be confusing.
bool: accept any letter case, or only True / False / T / F exactly?
Is identifier needed, or is string enough for Redux?
Planning note: #10 (is int / is set), #22 (is string) and #23 (number) cover most of this in 0.2.0. Whatever is left (size checks) is planned for 0.3.0 alongside #14's definition checking.
Activity
[-]Basic type and size checks in the grammar (Nice to Have)[/-][+](Low Priority) Basic type and size checks in the grammar[/+]Trosper3 commentedon Oct 1, 2026
Design: type and size checks
A proposal for this issue, for feedback before any code is written. It builds on #15 (
is int/is set/is listnow check their type) and #17 (is multiset).What exists today
K is intS subset intS is set,S is list,S is multiset(#17)Proposal
1. More built-in value types
These work like
inttoday:x is Tchecks one value, andS subset Tchecks every element.number3,-2,1.5,0.251,5,1e3,abcboolTrue,False,T,F, in any letter caseyes,1identifier_, then letters, digits or_:x1,node_33x,New Yorkstringstringmatches how Redux already writes DFA and NFA grammars (S is string,I is string). Today those parts are parsed but never checked (#14).numberuses a fixed format (digits, an optional sign and an optional decimal point) that doesn't change with the computer's language settings, so1,5is never read as one and a half.2. Non-empty and size
N is nonempty: at least one element. This is the common case, so it gets its own keyword.size N <op> n, with<op>one of=,<,<=,>,>=, andneither a number or another integer field of the same instance (as insize S <= K).Constraint size S <= K failed: S has 5 elements, K is 3.Grammar changes
number,bool,identifierandstringjoinintas built-in sets (lexer).nonemptyjoinsset,listandmultisetasiskeywords (lexer).'size' TERM COMPARE (TERM | number)(parser).Redux impact
Nothing breaks. Redux can then:
N is nonemptyto Partition and Subset Sum, replacing the checks hand-added in Backend bug fixes: clean 400s for bad input, solver fixes, parser hardening Redux#624;Comparing a certificate's size with the instance's
Kstill happens in Redux, because they're parsed separately.Open questions
nonemptyandsize? Or the set-builder style|S| <= K? That reads like the math, but|already separates the format from the constraints, which could be confusing.bool: accept any letter case, or onlyTrue/False/T/Fexactly?identifierneeded, or isstringenough for Redux?numberaccept exponents such as1e3?Trosper3 commentedon Oct 13, 2026
Planning note: #10 (
is int/is set), #22 (is string) and #23 (number) cover most of this in 0.2.0. Whatever is left (size checks) is planned for 0.3.0 alongside #14's definition checking.