Trying to make prolog give me possible solutions to a logical problem

I’m using: SWI-Prolog version 8.4.1

I want the code to:
trying to make prolog give me possible solutions to a logical problem. In my problem, a bot can be either switched on or off at any time T. Also, every bot can be switched by another bot, or a human (I call both agents ). Every bot is on by default and stays on unless an agent switches it. Switching takes effects at the next timestep (i.e. switching an off bot at T=1, makes it on at T=2) Given a bot X and a time T I want all possible switches that make X on at T So a simple example is bot X=digger at time T=2. Answers will be like this 1st answer: no switching 2nd answer: agent switches digger at T=0 to be off. agent switches digger back at T=1 to be on

But what I’m getting is:
ERROR: Arguments are not sufficiently instantiated, which is understandable, given I want to generate the time steps to switch in and also use the ‘is’ operator. I don’t know how to change the code exactly though.

My code looks like this:
This is the code I’ve written so far, but I seem to be getting something fundamentally wrong.

:- dynamic(switched/3).
                         not(X = Y).

human(me).

bot(digger).
bot(planter).
bot(cutter).
bot(gatherer).
bot(recharger).

agent(X) :- human(X);
            bot(X).

on(X, 0) :- agent(X).
on(X, T) :- LastT is T - 1, agent(A), T >= 0,
            off(X, LastT), switched(A, X, LastT);
            
            LastT is T - 1, agent(A), T >= 0, 
            on(X, LastT), not(switched(A, X, LastT)).

off(X, T) :- \+ on(X, T).

can_recharge(X, Y, T) :- agent(X), 
                         bot(Y), on(Y, T), 
                         not(X = Y).

Sorry for the poor titling, I don’t know a suitable title.

EDIT: Finish.

:- dynamic(switched/2).

human(me).

bot(digger).
bot(planter).
bot(cutter).
bot(gatherer).
bot(recharger).

agent(X) :- human(X);
			bot(X).

on(X, 0) :- agent(X).
on(X, Time, []) :- 
			agent(X), Time > 0,
			format('Solution is ~w ~n', [[]]);
			
			agent(X), Time > 0, LastTime is Time - 1,
			between(0, LastTime, H),
			on(X, Time, [H]).

on(X, Time, [H|Tail]) :- 
			agent(X), Time > 0,
			length(Tail, TailLength), TailLength < Time,
			LastTime is Time - 1, HNext is H+1, 
			between(HNext, LastTime, NewH),
			on(X, Time, [NewH, H|Tail]);

			agent(X), Time > 0,
			length(Tail, TailLength), TailLength =< Time, odd(TailLength),
			reverse([H|Tail], Solution),
			format('Solution is ~w ~n', [Solution]).

on_switched(X, T, switched(X, PastT)) :- T > PastT, on(X, T).

off(X, T) :- \+ on(X, T).

can_recharge(X, Y, T) :- agent(X), 
						 bot(Y), on(Y, T), 
						 not(X = Y).

even(N) :- N mod 2 =:= 0.
odd(N) :- \+ even(N).

While you can ask beginner Prolog questions here, answering such questions is not the primary goal of this site. A better place to seek help and more likely to receive a reply is at StackOverflow using the Prolog tag.