Prolog - The Solar System.

LA home
Computing
Logic
 Prolog
  Intro.
  Syntax
  Examples
   Windsor
   Append
   Aunt
   Solar
   Diff
   Tree
   Witch
Prolog is excellent for queries on relational data (as in the Mathematical sense of a "relation"), e.g.,
orbits(mercury, sun).  {facts}
orbits(venus,   sun).
orbits(earth,   sun).
orbits(mars,    sun).
orbits(jupiter, sun).
orbits(saturn,  sun).
orbits(uranus,  sun).
orbits(neptune, sun).

orbits(moon, earth).

orbits(deimos, mars).
orbits(phobos, mars).

orbits(ganymede, jupiter).
orbits(callisto, jupiter).
orbits(io,       jupiter).
orbits(europa,   jupiter).

orbits(titan,     saturn).
orbits(enceladus, saturn).

orbits(titania, uranus).
orbits(oberon,  uranus).
orbits(umbriel, uranus).
orbits(ariel,   uranus).
orbits(miranda, uranus).

orbits(triton, neptune).

planet(P)    <= orbits(P, sun).     {rules}
satellite(S) <= orbits(S, P) and planet(P).

? satellite(S).   {query}




www:

↑ © L. Allison, www.allisons.org/ll/   (or as otherwise indicated).
Created with "vi (Linux)",  charset=iso-8859-1,   fetched Friday, 23-Aug-2019 08:31:54 EDT.

Free: Linux, Ubuntu operating-sys, OpenOffice office-suite, The GIMP ~photoshop, Firefox web-browser, FlashBlock flash on/off.