<div dir="ltr">Hi Rui,<div><br></div><div>The problem with the following rule is that there are a bunch of hidden variables in the "not cinder:volumes(...)" literal. The error message shows the hidden variables. The syntax restriction is that every variable in a negative literal must appear in a positive literal in the body. Those hidden variables fail to satisfy that restriction, hence the error.</div><div><br></div><div><span style="font-size:14px;line-height:21px"> error(id) :- cinder:volumes(id=id), not cinder:volumes(id=id, status="available")</span><br><div><br></div><div>The reason the other rule worked is that you made the hidden variables equivalent to the ones in the positive literal, e.g. x_0_1 shows up in both the positive and negative literals. </div><div><span style="font-size:14px;line-height:21px"><br></span></div><div><span style="font-size:14px;line-height:21px">error(x) :- cinder:volumes(x, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8),not cinder:volumes(x, _x_0_1, _x_0_2, \"available\",_x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8)</span><br></div><div><span style="font-size:14px;line-height:21px"><br></span></div><div><span style="font-size:14px;line-height:21px">But in the auto-generated one, the variables in the two literals are different e.g. _x_0_1 and _x_1_1</span></div><div><span style="font-size:14px;line-height:21px"><br></span></div><div><span style="font-size:14px;line-height:21px">error(id) :- cinder:volumes(id, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8), not cinder:volumes(id, _x_1_1, _x_1_2, "available", _x_1_4, _x_1_5, _x_1_6, _x_1_7, _x_1_8). Unsafe lits: not cinder:volumes(id, _x_1_1, _x_1_2, "available", _x_1_4, _x_1_5, _x_1_6, _x_1_7, _x_1_8)</span><span style="font-size:14px;line-height:21px"><br></span></div><div><br></div></div><div>Probably the solution you want is to write 2 rules:</div><div><br></div><div>error(id) :- cinder:volumes(id=id), not avail_cinder_vol(id)</div><div>avail_cinder_vol(id) :- cinder:volumes(id=id, status="available")</div><div><br></div><div>Tim</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 13, 2015 at 8:07 PM Rui Chen <<a href="mailto:chenrui.momo@gmail.com">chenrui.momo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry, send the same mail again, please comments at here, the other mail lack title.</div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-14 11:03 GMT+08:00 Rui Chen <span dir="ltr"><<a href="mailto:chenrui.momo@gmail.com" target="_blank">chenrui.momo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:14px">Hi folks:</span><div style="font-size:14px"><br></div><div style="font-size:14px"> I face a problem when I insert a rule into Congress. I want to find out all of the volumes that are not available status, so I draft a rule like this:</div><div style="font-size:14px"><br></div><div style="font-size:14px"> error(id) :- cinder:volumes(id=id), not cinder:volumes(id=id, status="available")</div><div style="font-size:14px"><br></div><div style="font-size:14px"> But when I create the rule, a error is raised:</div><div style="font-size:14px"><br></div><div style="font-size:14px"><div>(openstack) congress policy rule create chenrui_p "error(id) :- cinder:volumes(id=id),not cinder:volumes(id=id, status=\"available\")"</div><div>ERROR: openstack Syntax error for rule::Errors: Could not reorder rule error(id) :- cinder:volumes(id, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8), not cinder:volumes(id, _x_1_1, _x_1_2, "available", _x_1_4, _x_1_5, _x_1_6, _x_1_7, _x_1_8). Unsafe lits: not cinder:volumes(id, _x_1_1, _x_1_2, "available", _x_1_4, _x_1_5, _x_1_6, _x_1_7, _x_1_8) (vars set(['_x_1_2', '_x_1_1', '_x_1_6', '_x_1_7', '_x_1_4', '_x_1_5', '_x_1_8'])) (HTTP 400) (Request-ID: req-1f4432d6-f869-472b-aa7d-4cf78dd96fa1)</div></div><div style="font-size:14px"><br></div><div style="font-size:14px"> I check the Congress policy docs [1], looks like that the rule don't break any syntax restrictions.</div><div style="font-size:14px"><br></div><div style="font-size:14px"> If I modify the rule like this, it works:</div><div style="font-size:14px"><br></div><div style="font-size:14px"><div>(openstack) congress policy rule create chenrui_p "error(x) :- cinder:volumes(x, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8),not cinder:volumes(x, _x_0_1, _x_0_2, \"available\",_x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8)"</div><div>+---------+------------------------------------------------------------------------------------------------+</div><div>| Field | Value |</div><div>+---------+------------------------------------------------------------------------------------------------+</div><div>| comment | None |</div><div>| id | ad121e09-ba0a-45d6-bd18-487d975d5bf5 |</div><div>| name | None |</div><div>| rule | error(x) :- |</div><div>| | cinder:volumes(x, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8), |</div><div>| | not cinder:volumes(x, _x_0_1, _x_0_2, "available", _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8) |</div><div>+---------+------------------------------------------------------------------------------------------------+</div></div><div style="font-size:14px"><br></div><div style="font-size:14px"> I'm not sure this is a bug or I miss something from docs, so I need some feedback from mail list.</div><div style="font-size:14px">Feel free to discuss about it.</div><div style="font-size:14px"><br></div><div style="font-size:14px"><br></div><div style="font-size:14px">[1]: <a href="http://congress.readthedocs.org/en/latest/policy.html#datalog-syntax-restrictions" target="_blank">http://congress.readthedocs.org/en/latest/policy.html#datalog-syntax-restrictions</a></div><div style="font-size:14px"><br></div><div style="font-size:14px"><br></div><div style="font-size:14px">Best Regards.</div></div>
</blockquote></div><br></div>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</blockquote></div>