Please assist me with following SWI complier error?

Main :- statistics(cputime, T0),
	write('hello'),
	statistics(cputime, T1),
	T is T1 - T0.
	format ('CPU time: ~w~n', T).

When compile the above code the next error is occurred:

Warning: d:/l.pl:1:
Warning:    Singleton variables: [Main,T]
ERROR: d:/l.pl:1:
ERROR:    Arguments are not sufficiently instantiated
ERROR: d:/l.pl:5:15: Syntax error: Operator expected

In Prolog words that start with upper case letters are variables. So instead of Main use main.


For

T is T1 - T0.

The period . at the end of the line ends the predicate. You don’t want to end the predicate on that line so use , instead.

T is T1 - T0,

For

format ('CPU time: ~w~n', T).

you have a space between format and (. You need

format('CPU time: ~w~n', T).

Here is a working version

File: example.pl

main :-
    statistics(cputime, T0),
	write('hello'),
	statistics(cputime, T1),
	T is T1 - T0,
	format('CPU time: ~w~n', T).

Example run

Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.28-20-g6f8a68f2b)
...

?- working_directory(_,'C:/Users/Groot').
true.

?- [example].
true.

?- main.
helloCPU time: 0.0
true.

Thank you very much for all you doing and i want all the best for you, I am beginner in pro log and excuse me if i have some simple questions, Please help me again in following code if it is possible:


I have 5000 facts same as

decision(admin,married,highschool,no,58,no,no)

if i want use a user predicate (decision) in the following code, What can I do? also my questions from rule-set are done with decision predicate and input variables in decision(X1,X1,)
Thank you

main :- statistics(cputime, T0),
	decision(X1,X2,X3,X4,X5,X6,Y), 
	statistics(cputime, T1),
	T is T1 - T0,
	format('CPU time: ~w~n', T).

Since your questions and errors indicate that you are very very new to Prolog you need to learn the basics. I and many here do not have the time to teach you Prolog.

My suggestion would be that you start off with Learn Prolog Now! and then progress through the classic Prolog books.

Thank you for your consideration