From ok@atlas.otago.ac.nz  Thu Mar 23 03:16:04 2000
Received: from atlas.otago.ac.nz (atlas.otago.ac.nz [139.80.32.250])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id DAA23336
	for <prolog@swi.psy.uva.nl>; Thu, 23 Mar 2000 03:16:03 +0100 (MET)
Received: (from ok@localhost)
	by atlas.otago.ac.nz (8.9.3/8.9.3) id OAA03894;
	Thu, 23 Mar 2000 14:16:04 +1200 (NZST)
Date: Thu, 23 Mar 2000 14:16:04 +1200 (NZST)
From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
Message-Id: <200003230216.OAA03894@atlas.otago.ac.nz>
To: hocaoglu@ece.arizona.edu, prolog@swi.psy.uva.nl
Subject: Re:  To read a file

Fatih Hocaoglu <hocaoglu@ece.arizona.edu> wrote:
	The program read a rule such as set_trust(on) from the knowledge base and
	assigned it to a variable, X='set_trust(on)'. How can I assert the
	predicate set_trust(on).
	
	I tried to use asserta(X), but it doesn't work,
	I think type conversion necessary.

set_trust(on) is a FACT (a kind of CLAUSE) not a PREDICATE.

The obvious question is "HOW did the program read this fact?"
Here's a little transcript:
1 ?- read(X), asserta(X).
|: set_trust(on).
<EOF>
X = set_trust(on) 

Yes
2 ?- listing(set_trust).

set_trust(on).

The important thing here is that X was NOT 'set_trust(on)' (an ATOM,
a single symbol) but set_trust(no) (a COMPOUND TERM, with FUNCTOR
'set_trust'/1 and argument 'no')).

When you tried asserta('set_trust(on)'), it actually succeeded.
You added a fact (better known as a unit clause) for a predicate
called 'set_trust(on)' with no arguments.

asserta/1 is uncommon, assert/1 is more usual.

It looks as though the problem is with the way you are reading clauses.
Use read/1.  Any good Prolog book will tell you how to do this; Sterling
and Shapiro certainly does.

