prologinstantiationuncaught-exception

uncaught exception: error(instantiation_error,(=<)/2)


Im trying to code a board thats 7x7 and I need to set and check the limits of the board, so I made de following function:

lim(X, Y) :- 
    X =< 7,
    X >= 1,
    Y =< 7,
    Y >= 1.

But it keeps giving me the error "uncaught exception: error(instantiation_error,(=<)/2)".

Does anyone have any idea of how to fix this?

I tried to change to:

lim(X, Y) :- 
    X < 8,
    X > 0,
    Y < 8,
    Y > 0.

But it gives me the error "uncaught exception: error(instantiation_error,(<)/2)", and I dont know what to do.

I tried to search the error as well and what I saw said that this error ocurs because I do not use the variables X and Y, so I changed it to X -> La and Y -> Ca, this are the variables that I use but the same error appears, so this is the new limit function:

lim(La, Ca) :- 
    La =< 7,
    La >= 1,
    Ca =< 7,
    Ca >= 1.

For more context the first part of the code is as follows:

% state -> e(AgentLine, AgentColumn, MachineLine, MachineColumn)

inicial_state(e(1, 2, 2, 2)).
final_state(e(_, _, 7, 2)).

%restrictions
obsta(e(6, 1)).
obsta(e(6, 3)).
obsta(e(7, 4)).
obsta(e(4, 4)).
obsta(e(3, 4)).
obsta(e(2, 4)).
obsta(e(6, 7)).

lim(La, Ca) :- 
    La =< 7,
    La >= 1,
    Ca =< 7,
    Ca >= 1.

equals(A, A).

%state operator -> op(actual_state, operator, next_state, cost)
op(e(La, Ca, Lm, Cm), up, e(Ls, Cs, Lms, Cms), 1) :-
    Ls is La + 1.

Solution

  • Just use: between(1, 7, X), between(1, 7, Y). Credits to: brebs