MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: prolog like search

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76638] Re: prolog like search
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Fri, 25 May 2007 06:27:50 -0400 (EDT)
  • References: <f33rbj$mod$1@smc.vnet.net>

siewsk at bp.com wrote:
> I would like to do prolog like searches in Mathematica
> 
> entities={ william , henry , diana , charles }
> Sonof(william,diana);
> Sonof(william,charles);
> Sonof(henry,diana);
> Sonof(henry,charles);
> 
> Married(A,B) := Sonof(S,A) && Sonof(S,B) && A != B;
> 
> PrologSearch(Married,entities)
> 
> returns { Married(diana,charles), Married(charles,diana) }
> 
> Any idea how this could be implemented in Mathematica?
> 
> 
I think it would be possible in principal to write an interpreter for 
PROLOG in Mathematica, but of course, it would not be particularly fast!

There is no trivial relationship between the two languages, because, for 
example, PROLOG programs have a deep backtrack stack that is not part of 
Mathematica.

Obviously, it would be possible to solve the problem that you present, 
but I assume you are interested in more general PROLOG programs.

Can you  tell us why you want to do this - there is almost certainly a 
better solution!

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: I want some help about ContourPlot function
  • Next by Date: Re: What to do in v. 6 in place of Miscellaneous`RealOnly
  • Previous by thread: Re: prolog like search
  • Next by thread: Re: prolog like search