Check array of statements against state array

Hi everyone,

I am experimenting with this planner: Prolog Planner (

I already modified the planner a bit to allow for the action incrementValue which works.

My actions look like this:

move(plus(), [value(someVal, X)], [incrementValue(someVal, X , 1)]).
move(minus(), [value(someVal, X)], [incrementValue(someVal, X , -1)]).

And it works fine.

go([value(someVal, 10)], [value(someVal, 5)])
moves are:

But now I want to extend the functionality by changing the value based on X:

move(plus(), [value(someVal, X), X >= 10], [incrementValue(someVal, X , 1)]).
move(plus(), [value(someVal, X), X < 10], [incrementValue(someVal, X , 0.1)]).

But this does not work currently. To compare the precondition to the state the algorithm uses:


member_set(E, S) :- member(E, S).

subset([], _).
subset([H|T], S) :- 
    member_set(H, S), 
    subset(T, S).

conditions_met(P, S) :- subset(P, S).

As far as I understand it the X condition is not checked here, as it is only checked if P is a subset on S and not if P is true given the statements in S. Can you give me a hint how I can really evaluate those statements?

I am quite new to Prolog so I am glad for any help and would even appreciate some tutoring or pay for it maybe. Thanks a lot

Just a quick look. I did not try to run your code.

Why do you have two actions with the same name, plus?

move(plus(), [value(someVal, X), X >= 10], [incrementValue(someVal, X , 1)]).
move(plus(), [value(someVal, X), X < 10], [incrementValue(someVal, X , 0.1)]).

I would have expected something like plus_whole and plus_decimal.

I want the action plus to behave differently depending on the value of X. So I have two different rules for plus - one if the value is smaller 10, the other if it is bigger

The use case is to encode the behavior of a device where the interaction with a button has a different effect depeding on the current value.

I understand that, but is that causing the logic to fail? I don’t want to take the time to debug this to find out so am asking you.

A while back I answered a question on StackOverflow using the referenced code.

So I know how much work it takes to get this working correctly.

As far as I get it the statement X >= 10 or any similar is not evaluated and therefore the precondition never matches. It also does not work with only one condition. I think this is because the X >= 10 is no subset of the state. So the algorithm only cares if the precondition is a subset of the state but not if the preconditions are true given the state.

For example, if I print the state and the precondition I see this result, but the condition is not fulfilled.

[value(someVal,_3996),_3996>=10] (P)
[value(someVal,10)] (S)

Since your first post was quite open ended, other such topics have come up on this forum before noting planner.

Two other points of mention for these types of problems.

In other words, there is a reason finding Prolog code using planners is hard, other ways might be more productive and faster.

Thanks for your input, first of all.

I have already searched for other search algorithms but almost all of the search implementations base on graph search or something like planning actions where actions change a single state clause. I have not found any implementations that have these numerical constrainst that I need.

The problem with your question is that it leaves more questions than it answers, E.g.

  1. Does your problem need to show the steps from the premises to the conclusion?
  2. Can the problem be solved with a set of constraints?
  3. Is the input just numerical?
  4. Is the output just numerical?
  5. What are the properties or attributes that could be used in guards? Attributes as noted here could also be the specific types of attributes used with Prolog and constraints?
  6. Are you aware of CHR for creating a new constraint solver? (I have not used these so can only ask.)
  7. Would SSU work?
  8. Does it need a different logic like used in Picat?
  9. Would tabling help?

That is a lot to think about. Thanks for your help

If instead of thinking about it which could drive one nuts trying to understand all of that, if you write your problem down like a homework problem giving all of the details necessary to solve the problem then we could provide more specific guidance.