Block world problem code in python7/4/2023 ![]() ![]() But you shouldn't need that sort of fancy encoding for the classic block/planning problems. If you introduce objects from an infinite domain, like Int, Real, etc., things would get more interesting and possibly too hard for z3 to deal with. At the 1953 coronation of Britain’s Queen Elizabeth II, a simple gesture from her younger sister caused a royal ruckus and eventually heartache. But by keeping the universe finite (and small!), they can handle any number of such axioms rather well. I should note that SMT solvers are usually not good at quantified reasoning. Which is a valid scenario, satisfying all the constraints. ![]() But you can modify and play around with different axioms and see what sorts of models you get.) I also added two axioms saying On and Above are irreflexive. (Note that I had to tweak your P2, which didn't look quite right. If you want to generate the problems randomly, you need this page instead. In the goal, block 2 is on the table, block 1 on top of it and block 3 again on block 1. Solver.add(ForAll(, Implies(And(On(x, z), Above(z, y)), Above(x, y)))) Initially blocks 1 and 2 are on the table and block 3 is on block 1. Solver.add(ForAll(, Implies(On(x, y), Above(x, y)))) On = Function ("On", Block, Block, BoolSort())Ībove = Function ("Above", Block, Block, BoolSort()) This will make the coding much closer to how planning systems are typically coded, and will also help with interpreting the models themselves.īased on this, here's how I'd go about coding your problem, assuming we live in a universe with three blocks named A, B, and C: from z3 import *īlock, (A, B, C) = EnumSort('Block', ('A', 'B', 'C')) I think your coding is a fine start, but you'd be better served by making Block an enumerated sort and declaring the blocks in your system explicitly. Coding might be more verbose, and as you found out interpreting models can be rather tricky. But you will not get the nice features of a dedicated system for obvious reasons. Such problems are surely solvable by Z3, and by any SMT solver in general. And it appears z3 cannot do this without having the post conditions explicitly programmed. I would think implication but I haven't had much luck with this and it seems this technique relies on new constraints to be generated from the effects/post-conditions after the preconditions are satisfied in the model. How can I fix this? and where can I find a good resource for encoding planning problems to SAT? I have seen STRIPS formalism but it is unclear to me how to encode pre+post conditions into logic props. P2 = ForAll(, Implies(And(On(x,y), Above(z, y)), Above(x,y)))īut this outputs to something that looks like gibberish to me. On = Function ("On", blk, blk, BoolSort () )Ībove = Function ("Above", blk, blk, BoolSort () )Ī, b, c, x, y, z = Consts ("a b c x y z", blk ) My attempt looks like #!/usr/bin/env python For instance I really want to find an example of the Sussman anomaly/blocks world in z3 but have not been able to find anything. I am interested in using z3 for solving planning problems but I am having difficulty finding examples. ![]()
0 Comments
Leave a Reply. |