(See 'materials' for background and software used for the tutorial)
Role in Kinship section assignment (50% of Term 1 assessment).
Part of the assignment is the entry of your kin in the Kinship Editor (see 'materials' for background and software for doing this.). This is necessary to do the exercises for the remaining workshops.
This document covers a formative exercise. It is assessed as part of the Kinship Assessment.
Purpose
The purpose of this section of the course is to experience kinship as an active area of human knowledge, to gain some appreciation for the complexity that kinship and kinship terminologies simplify in socieity, and to develop understanding about how computers can be applied to help us with essentially symbolic issues and problems.
Assignment
The assignment consists of producing a working definition in the prolog programming language for each English Kinship term in the list (a) of kinship terms below., and attempt a definition for the terms under list (b), which may not work properly. You can test most of the relationships by using your kin and seeing if they work.
(a)
father, mother, brother, sister, daughter, son, grandfather, grandmother, aunt, uncle, cousin, wife, husband, father-in-law, mother-in-law, sister-in-law, brother-in-law, son-in-law, daughter-in-law
(b)
first-cousin, second-cousin, half-sister, half-brother, great-great-grandfather, great-great-grandmother, grand-aunt, grand-uncle, ancestor, descendent., patrilineal ancestor, matrilineal ancestor
Prolog
See the prolog notes. and the Programming Kin section of the ERA tutorial. You will make life easier for yourself if you also read the Calculating Kin section.. Note that the underlying approach in these materials is directed towards using kin type definitions. We are not following this approach in this part of the assignment, so you cannot copy the definitions in the Era tutorial to satsify the assignment. However, the Era materials will be very useful. The logic is the same, just the details are different.
Converting your kinship editor file to a prolog program.
Use the ConvertKin application ( see 'materials') to convert your kinship editor file to prolog. Double click on ConvertKin, select 'Convert' from the File menu, and find your file using the file dialog (you can also drag your kinship editor file and drop it on to the file dialog to save time). It will make a file with the same stem, with extension .pl. That is, mykin.kin, will be translated to mykin.pl.
Load your translated kinship file into Prolog.
Double-click on XMLProlog_2002.jar ( see 'materials') to start Prolog. Load your kinship.pl file by clicking on the 'Load' button, and find your file using the file dialog (you can also drag your kinship editor file and drop it on to the file dialog to save time). You will see the program text in the middle window. Scroll through, and you will find that all of the names you entered in the kinship editor, with a number appended. This is a unique ID so that different people with the same names don't clash with each other.
Representing Kinship
For people, the following information is available:
male('name').
female('name').
sibset('name','id').
spouseset('name','id').
born('name','birth_year').
died('name','death_year').
NA in a value means that the property is unknown or not applicable, '' means it is missing. Missing values must be indicated by two single quotes, as in sibset('john_1','').
Note that most things are in lower case (a-z). This is because prolog assigns special meaning to upper case (A-Z). If, as in the case of NA above, we want to use upper case we must put it in quotes (' ').
sibset refers to the descendents from a union in the kinship editor. spouseset refers to the people who have some kind of spouse-like relationship to each other. These are not standard terms in anthropological use. I use them because they can be converted easily into a number of more conventional ways of representing relationships, and they avoid fixing one orientiation over another.
union is the basic way of connecting people together in the kinship editor model, and the following information is available about unions.
union_start('ID','Year of beginning').
union_end('ID','Year of ending').
We will not need to refer to the union information in union_start and union_end much in this exercise. Most of the union information is implicit because it is stored with people in the sibset and spouseset facts.
In prolog terms this kind of information is called a 'fact'. It is a fact not in any philosophical sense, but rather because prolog allows you to assert whatever you want as a fact.
Rules
Rules are the way that you write programs in prolog. Essentially a rule is a logical equation. There are three rules that are put in by the ConvertKin application that appear at the end of the file (scroll down to the end). These are child, spouse and sibling.
These rules are present to convert the pragmatic way I stored the data from Kinship Editor as spousesets and sibsets into a more conventional form.
The first, child, is illustrated in diagram 1.
diagram 1
Diagram 1 shows how prolog defines a rule (or equivalence) between child and sibset and spouseset. child is thus a derived fact. That is, once we have defined child in terms of sibset and spuseset facts, we can use it just as if it were a fact itself.
Notice that in the rule that we use upper case letters (X,Y,Z) instead of names and id values that actually appear in the spouseset and sibset facts. Prolog assigns a special meaning to upper case letters (or any word that begins with an upper case letter). These are usually called variables, and range over the possible set of values in corresponding facts.
Within a rule, X will refer to the same value everywhere it appears in the rule. Likewise Z will match all other Zs etc. That is, although variables don't have a fixed value, all variables of the same name always have the same value throughout a rule.
Translated into English, the child rule says,
person X is a child of person Y when the sibset id (Z) of X is the same as the spouseset id (Z) of Y. Or, X is a child of Y when X is a child of a union and Y is a parent in the same union.
We can go on to define a rule for parent:
parent(X,Y) :- child(Y,X).
That is, X is parent of Y when Y is child of X.
This might sound a bit tedious, but it is necessary to represent our knowledge that parent is the inverse of child directly in prolog. It can't figure this out automatically. So representing kinship terms consists of representing our knowledge about terms and what they refer to in the form of prolog rules.
Using Rules
In most common programming languages you write a program by defining in great detail each step that needs to be completed to do a particular task. These are called procedural languages.
Prolog is a declarative language. That is, instead of specifying a lot of steps, you define a set of logical equilances (as in previous section). To run the program you present prolog with a goal. It then figures out the steps necessary to satisfy that goal. This is a very useful approach to representing knowledge where that knowledge is largely symbolic and structural rather than numeric.
If you have loaded your kinship.pl file into prolog (you see the program in the middle window), then you can execute a goal immediately. In the top window, labelled Query, is the goal,
child(Who,Whom).
If you click the Consult button to the right, the bottom window will eventually list all the solutions to the query. That is, prolog finds all the pairs of people for who the child relationship is true.
Adding Rules
The syntax for making a prolog rule is very simple. Add a rule for parent at the end of the Program window (just click at the end and enter ...)
a) what is the derived fact to be defined,
parent
'(' followed by variables for each position in the derived fact, followed by ')'.
parent(Q,R)
':-' which denotes a definition follows
parent(Q,R) :-
an existing fact or defined rule name
parent(Q,R) :- child
'(' followed by variables or constants (e.g. actual values) followed by ')'
parent(Q,R) :- child(R,Q)
finally a full stop '.'
parent(Q,R) :- child(R,Q).
This full-stop is very important, and the program will fail if any of these are missing.
You can also have more than one clause in the definition:
father(X,Y) :- parent(X,Y), male(X).
In this rule we define father in terms of a derived fact, parent and a basic fact male. It basically says, in English that X is a father of Y when X is a parent of Y and X is male, e,g, a male parent.
We can then enter the goal
father(Who, Whom)
int the top window, click Consult and get a list of all fathers at the bottom. [You must click consult after changing the program, or the new rules will not be available.]
Note that Who and Whom are just different terms that start with an upper case letter to prolog. Any other word starting with an upper case letter would do, as long as each is unique.
You can also enter in a partial query:
father(george_2, Whom)
in the goal, Consult button clicked, and we will get a list of everyone that george_2 is father of.
Proceeding with the other terms, you should be able to define each in a similar manner, and test the results against your knowledge of relationships in your family.
Complex Rules
So far we have just expressed relatively simple rules: an inverse for child we call parent, and a special case of parent we call father.
The logic behind making more complex rules is very simple, though it is a bit confusing, especially when you try to say them in words ...
Let's try a rule for aunt
In English Kinship Terminolgy (EKT) aunts are sisters of your parents. In other socities there is a different term for sister of mother than sister of father. So how a definition is made is culturally specific.
From our simple definition above for EKT, we might want to capture our knowledge about sisters before we attempt aunt.
A sister is a female sibling.
sister(X,Ego) :- sibling(X,Ego), female(X).
An aunt is a sister of a parent.
aunt(X,Ego) :- ....
Well, how to go about this? One easy way to think about this is to start at Ego, and step towards the aunt relation, one step at a time. So to find the sister of a parent, we first have to find parent of Ego.
aunt(X,Ego) :- parent(Somebody, Ego) ...
now we just have to find the sister of Somebody to complete the definition:
aunt(X,Ego) :- parent(Somebody, Ego), sister(X,Somebody).
But that only gets some of the aunts in EKT. Another definition for aunt is wife of brother of parent. We can define define wife, (do this as an exercise). The second definition for aunt could then be stated:
aunt(X,Ego) :- parent(Somebody, Ego), brother(B,Somebody), wife(X,B).
Having two rules to define a term is not a problem for Prolog. It will try the first, and then the second.
This logic can be extended to more complex relationships, such as first cousin. A first cousin is the child of an uncle or aunt, which follows the same logical form as second definition of aunt above. But what about a half-sister?
A half-sister is someone who shares a parent and who has a different sib-set.
half-sister(X,Y) :- female(X), parent(P,X), parent(P,Y), sibset(X,Id1), sibset(Y,Id2), neq(Id1,Id2).
Which specifies that half-sister is female, has a parent in common with ego, and whose sibset id is different from ego. However, this might fail if their parents had married, divorced and remarried between ego and the person being related ... they would have a parent in common and different sibsets, but would also have another parent in common. The following covers this:
half-sister(X,Y) :- female(X), parent(P,X), parent(P,Y), parent(Q,X), sibset(R,Y), neq(Q,R), neq(P,Q), neq(P,R).
This is lengthy, but necessary ... because prolog ranges over all possible solutions, it is possible for Q to be the same as P or R, and the rule would be true at some point for all siblings. Since we want exactly one parent in common, we have to check.


Web resources
The tutorial is based on material found in the Experience Rich Anthropology project at
http://era.anthropology.ac.uk/Era_Resources/Era/Kinship/
This should explain most of the intellectual issues involved, and also some background on the Kinship Editor (with which you enter the kinship data used in this tutorial) and Prolog.
Software
The following programs should be installed on your computer if you do not already have these.
KinProlog.zip Contains ConvertKin.jar which converts .kin files from the Kinship Editor to Prolog. This is a 'mac os x only' application and XMLProlog_2006.jar, A version of prolog that is easy to operate for small projects. This will run on any operating system that has java 1.1 or better installed.