🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #860

Transfer from sicstus to Turbo Prolog

#860
From: jrfang%peruvian.utah.edu
Date: Thu, 31 May 1990 16:43
91 lines
2447 bytes
Hi,

  We have an assignment in this quarter about backward chaining. I try to 
use Turbo Prolog, but it seems has many troubles in it. 

/* Things that can be asked of the user are recorded as:
         askable(<goal>).

   Rules are recorded as:
         rule(<name>, <lhs-goal>, [<rhs-goal-1>, ..., <rhs-goal-n>]).

   Queries are written as:
         [<goal-1>, ..., <goal-n>] */


/* The empty query is always successful. */

backward([]).


/* A singleton query can be answered by the user if it is askable. */

backward([Goal]) :-
  askable(Goal),
  askUser(Goal).


/* A singleton query can be expanded if a rule is applicable. */

backward([Goal]) :-
  rule(_, Goal, Condition),
  backward(Condition).


/* A compound query can be solved recursively. */

backward([Goal | Goals]) :-
  \+(Goals = []),
  backward([Goal]),
  backward(Goals).



/* We assume that Goal is variable free.  This succeeds if the user says
   yes, explains and retries if the user says why,  and fails otherwise. */

askUser(Goal) :-
  write('Is this true: '),
  write(Goal),
  nl,
  read(X),
  (X = yes; (X = why, write('Unknown'), nl, askUser(Goal, Why))).



/* Now some sample program rules. */

rule(r1, isMammal(X), [hasHair(X), warmBlooded(X)]).

rule(r2, isBird(X), [hasFeathers(X), laysEggs(X)]).

rule(r4, isCat(X), [isMammal(X), purrs(X)]).

rule(r5, isRobin(X), [isBird(X), canFly(X)]).

rule(r5, isEmu(X), [isBird(X), cantFly(X)]).

askable(hasHair(_)).

askable(warmBlooded(_)).

askable(hasFeathers(_)).

askable(laysEggs(_)).

askable(purrs(_)).

askable(canFly(_)).

askable(cantFly(_)).

How can I transfer the clause like
  rule(r1, isMammal(X), [hasHair(X), warmBlooded(X)]).
into Turbo Prolog? It seems in Turbo Prolog does not have the form like
(..[..[..]..]) (not list).

Thank!!!
--------


	
Technical Details
Message-ID: <1990May31.104306.26630@hellgate.utah.edu>
Path: arc1-ca.pugleaf.net!utzoo!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!helios.ee.lbl.gov!hellgate.utah.edu!peruvian.utah.edu!jrfang

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!helios.ee.lbl.gov!hellgate.utah.edu!peruvian.utah.edu!jrfang
From: jrfang%peruvian.utah.edu@cs.utah.edu
Newsgroups: comp.lang.prolog
Subject: Transfer from sicstus to Turbo Prolog
Message-ID: <1990May31.104306.26630@hellgate.utah.edu>
Date: 31 May 90 16:43:05 GMT
Article-I.D.: hellgate.1990May31.104306.26630
Organization: University of Utah CS Dept
Lines: 91
X-Local-Date: 31 May 90 09:43:05 PDT