feat(math): add Latin squares domain with check and transversal search (#1887) - #2021
feat(math): add Latin squares domain with check and transversal search (#1887)#2021morluto wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
morluto
left a comment
There was a problem hiding this comment.
Review verdict: blocked on the request contract and search bound
latin_square.transversal.compute says it searches a Latin square, but TransversalRequest checks only squareness. It accepts out-of-range symbols and matrices with repeated symbols in rows/columns, then returns a result under a stronger mathematical label than the input satisfies. Please reuse/wrap the validated LatinSquareRequest, or deliberately rename the operation to a transversal/rainbow-matching search over arbitrary arrays.
That missing validation also exposes a severe runtime case. The accepted matrix whose every row is
[0, 1, ..., n-2, n-2]has only n-1 symbols and therefore no full transversal. The naive DFS enumerates a factorial-scale family of partial assignments before proving failure. In an independent instrumentation of this exact algorithm, the n=10 case took 1,863,219 recursive calls and n=11 exceeded 10,000,000 calls; the public bound is n=20 with no work budget or incomplete status.
Validating Latin-ness removes this particular adversarial input, but exact transversal search can still be combinatorial. Please either establish a defensible smaller bound with worst-case tests, or expose a bounded-search contract (max_nodes plus complete/incomplete status) rather than presenting every accepted order-20 request as a routine total operation.
The Latin-square checker itself is correct under its 0..n-1 input contract.
Add latin_squares_ops domain with 3 operations: Latin square verification, orthogonality check, and transpose. Uses exact combinatorial checks over bounded n x n matrices. Closes #1887
553fec1 to
266c17e
Compare
Deep review summaryVerdict: REQUEST CHANGES — the transversal request does not require a Latin square, and the advertised order bound is not computationally defensible.
The missing validation also exposes a severe runtime case. An accepted matrix whose every row is [0, 1, ..., n-2, n-2]has only Validating Latin-ness removes that specific adversarial matrix, but exact transversal search remains combinatorial. Either establish a much smaller defensible total-operation bound with worst-case tests, or expose a bounded-search contract such as The Latin-square checker itself is correct under its |
Follow-up review for current head
|
Summary
Create the domain with two operations, partially addressing #1887.
Operations
latin_square.check— Validate whether a square matrix of order n with entries in 0..n-1 is a Latin square (no repeated symbols in any row or column).latin_square.transversal.compute— Exact backtracking search for a transversal (one entry per row, all distinct columns and symbols) in a Latin square.Tests
9 known-answer and adversarial tests covering:
Continue this on Linzumi