19. Instantiation, predicate
Consider the Prolog database from the previous page:
- Fact: spouse (john, jane)
- Fact: spouse (david, mary)
- Fact: spouse(george, susan)
- Fact: female (jane)
- Fact: female (mary)
- Fact: female (susan)
- Fact: male (john)
- Fact: male (david)
- Fact: male (george)
- Rule: husband(A,B) IF spouse(A,B) AND male (A)
- Rule: wife (A,B) IF spouse(A,B) AND female(B)
Predicate Logic
In the examples discussed so far, the goal
wife(david,mary)?
was declared.
The wife part is called the 'predicate'. The predicate is a logic statement that will be checked to determine if it is true or false. If it is true, a specific value will be returned.
For example, the predicate
son(john)?
is certainly false as far as this database is concerned as there is no such fact or rule for 'son'.
The predicate contains 'arguments' that need to be checked. So david and mary are the arguments of the predicate 'wife'.
wife(david,mary)?
Prediicates that may find a match within this database are
spouse female male husband wife |
Instantiate
A predicate can be declared with an unassigned value, like so
spouse(A,mary)
The 'A' argument is unassigned. This is asking the predicate logic question: "Does Mary have a spouse and if so, return the name of the spouse?"
The database will be scanned, the predicate is found to be true and 'david' is returned as 'A'.
The technical term to describe assigning values to the arguments of a predicate from within the database is called 'instantiation'
For example
The predicate: female(A) within this database can have the 'A' argument instantiated to any matching fact. In this case, the predicate can be instantiated to
jane mary susan |
Copyright © www.teach-ict.com