ABSTRACT

At its simplest level, a Prolog system works by comparing facts in a database with a query called a goal presented at the prompt. Consider as an example some facts holding information about depositors and borrowers in a building society. A depositor fact contains an account number followed by the customer name and balance, whereas a borrower fact contains a loan number followed by a name and the loan amount:   depositor(123, smith, 500).   depositor(234, brown, 200).   depositor(345, patel, 700).   borrower(735, jones, 2000).   borrower(674, patel, 6000).   borrower(865, evans, 5000). Collections of facts with the same name are called procedures or relations, and the individual instances are called clauses. Each fact consists of an identifier name followed by a number of arguments contained in brackets together with a terminating full stop. Prolog distinguishes between atomic and numeric constants by requiring atomic constants to begin with a lower case letter and numeric constants to begin with a digit. Thus, depositor, borrower and the names smith, brown, etc., are symbolic constants whereas the numbers are numeric constants. A string of characters beginning with a capital letter represents a variable, but when enclosed in single quotes, e.g. “Jones”, the string is taken as an atomic symbol. Prolog will accept facts in which numeric and symbolic arguments have been entered inconsistently because it is not a typed language, so a great deal of care is required.