Introduce the following fact in the prologue

I'm studying the prologue. I'm wondering how can I represent the following fact in the prologue?
"There are 300 miles between someCityA and someCityB." Anyone can help. I've searched for it enough but couldn't find a solution to my specific problem.

+3


source to share


1 answer


The prologue allows you to represent knowledge by facts and rules. fact and rule have the following format:

  A :- A1, .., An

      

Where A, A1, .., An are so-called literals. If n = 0, then its a fact; if n> 0, then this is a rule.

The literal has the following syntax, name is the name of the predicate and the members are the arguments of the predicate:

  literal = atom [ "(" term { "," term } ].

      

Knowledge representation is an art in itself. There can be many requirements for a presentation that can cause it to have a specific shape.

But you can think of it as a literal like an excel sheet that is used to hold a table. Columns that describe column names are not included in Prolog as facts and rules, but you can use Prolog comments to enter column names, for example:



  % distance_between_cities(Atom, Atom, Float)

      

Or more specifically:

  % distance_between_cities(CityId, CityId, DistanceMiles)

      

After the first comment, you simply enter the facts:

  distance_between_cities('New York, US','Los Angeles, US',2443.85).
  distance_between_cities('New York, US','San Francisco, US',2563.89).
  distance_between_cities('Los Angeles, US','San Francisco, US',347.18).

      

Different predicate names can name different excel sheets so to speak. Some prologue systems even have CSV interfaces.

Bye

+2


source







All Articles