-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
synthesize: Failing to generate a sudoku puzzle #205
Comments
Hello, The way your synthesis query is formulated is slightly wrong. The desired query is this: there exists a clue-grid Below is the modified query, and I've changed the rest of the code slightly to accommodate it. The modified query works for N = 35, for example, while the original one doesn't work for N < 40. This bound for the original query might be related to the mathematics of Sudoku: https://cs.stackexchange.com/questions/163/minimum-number-of-clues-to-fully-specify-any-sudoku I haven't had the patience to wait for N = 24 to come back for the modified query :)
|
Thank you for the quick answer! The changes you made make sense to me, and I understand why your version successfully synthesizes. However, I couldn't understand why the query in my version is asking for something stronger. Perhaps this is missing some nuance, but here's my thought process: Let P = there exists a clue-grid Let Q = for all Fix some I edited your version into this simpler program where
Should I adopted your changes and rewrote
This leads me to believe my understanding of what Any further guidance would be greatly appreciated :) |
Yes, Essentially, the classic "\exists\forall" query will synthesize a "vacuous" program whenever the precondition of that query is equivalent to "false". It's fine to return any program in that case, because there are, of course, no inputs that satisfy its precondition. Rosette's The following snippet demonstrates the difference:
|
Yes, that makes sense, but the mismatch I encountered is that |
I looked into this more, and it turns out that Rosette's CEGIS implementation was solving for a formula that's too strong. Instead of solving for ∃ H. (∃ I. pre(H, I)) ∧ (∀ I. pre(H, I) ⇒ post(H, I)), as intended, it was actually searching for more than one input that satisfies the precondition. That's why I've pushed a patch to the implementation, which now requires just one input to satisfy the precondition. Your examples work as expected with the patched query (modulo the 24-clue example taking longer than I have the patience to wait :). Great catch; thank you! P.S. I'd still recommend using the solution that quantifies over fewer variables, as the smaller number of quantified variables leads to better performance. |
Glad I could help, and thanks for the advice! |
Hello,
I'm attempting to generate a sudoku puzzle with
N
clues. A valid sudoku puzzle can have only one distinct solution, so I'm synthesizing a set of clues such that any two solutions that satisfy the clues must be equal.This approach works when
N
is set to a high value (e.g. 50 or 81), butsynthesize
returns(unsat)
whenN
is set to a lower value for which sudokus still exist (e.g. 24).I'm using Rosette 4.0 on a snapshot build of Racket (8.3.0.5). Here's the code:
I've tried similar approaches using
choice*
and bitvectors, but I hit the same issue every time. I'd really appreciate some help finding any mistake here that I'm not seeing.PS: Thank you for the excellent tool!
The text was updated successfully, but these errors were encountered: