// The Lehigh University Benchmark (LUBM)
// http://swat.cse.lehigh.edu/projects/lubm/
// ported by Anthony Potter
//
// Unary relations
.decl University (a:symbol)
.output University ()
.input University ()
.decl Person (a:symbol)
.output Person ()
.decl Employee (a:symbol)
.output Employee ()
.decl Faculty (a:symbol)
.output Faculty ()
.decl Professor (a:symbol)
.output Professor ()
.decl Course (a:symbol)
.output Course ()
.input Course ()
.decl AssociateProfessor (a:symbol)
.input AssociateProfessor ()
.decl AssistantProfessor (a:symbol)
.input AssistantProfessor ()
.decl Organization (a:symbol)
.output Organization ()
.decl Chair (a:symbol)
.output Chair ()
.decl Work (a:symbol)
.output Work ()
.decl Lecturer (a:symbol)
.output Lecturer ()
.input Lecturer ()
.decl Student (a:symbol)
.output Student ()
.decl GraduateStudent (a:symbol)
.input GraduateStudent ()
.decl ResearchAssistant (a:symbol)
.input ResearchAssistant ()
.decl GraduateCourse (a:symbol)
.input GraduateCourse ()
.decl UndergraduateStudent (a:symbol)
.input UndergraduateStudent ()
.decl ResearchGroup (a:symbol)
.output ResearchGroup ()
.input ResearchGroup ()
.decl Publication (a:symbol)
.output Publication ()
.input Publication ()
.decl TeachingAssistant (a:symbol)
.output TeachingAssistant ()
.input TeachingAssistant ()
.decl FullProfessor (a:symbol)
.input FullProfessor ()
.decl Department (a:symbol)
.input Department ()

// Binary relations
.decl hasAlumnus (a:symbol, b:symbol)
.output hasAlumnus ()
.decl degreeFrom (a:symbol, b:symbol)
.output degreeFrom ()
.decl member (a:symbol, b:symbol)
.output member ()
.decl teachingAssistantOf (a:symbol, b:symbol)
.input teachingAssistantOf ()
.decl headOf (a:symbol, b:symbol)
.input headOf ()
.decl teacherOf (a:symbol, b:symbol)
.input teacherOf ()
.decl publicationAuthor (a:symbol, b:symbol)
.input publicationAuthor ()
.decl doctoralDegreeFrom (a:symbol, b:symbol)
.input doctoralDegreeFrom ()
.decl undergraduateDegreeFrom (a:symbol, b:symbol)
.input undergraduateDegreeFrom ()
.decl mastersDegreeFrom (a:symbol, b:symbol)
.input mastersDegreeFrom ()
.decl subOrganizationOf (a:symbol, b:symbol)
.output subOrganizationOf ()
.input subOrganizationOf ()
.decl takesCourse (a:symbol, b:symbol)
.input takesCourse ()
.decl worksFor (a:symbol, b:symbol)
.output worksFor ()
.input worksFor ()
.decl memberOf (a:symbol, b:symbol)
.output memberOf ()
.input memberOf ()
.decl advisor (a:symbol, b:symbol)
.input advisor ()
.decl emailAddress (a:symbol, b:symbol)
.input emailAddress ()
.decl telephone (a:symbol, b:symbol)
.input telephone ()
.decl name (a:symbol, b:symbol)
.input name ()
.decl researchInterest (a:symbol, b:symbol)
.input researchInterest ()

// Ontology
University(Y) :- mastersDegreeFrom(_,Y) .
degreeFrom(X,Y) :- hasAlumnus(Y,X) .
hasAlumnus(X,Y) :- degreeFrom(Y,X) .
Employee(X) :- Faculty(X) .
Faculty(X) :- Professor(X) .
Professor(X) :- AssociateProfessor(X) .
Person(Y) :- member(_,Y) .
Professor(X) :- AssistantProfessor(X) .
Professor(X) :- Chair(X) .
worksFor(X,Y) :- headOf(X,Y) .
Person(X) :- degreeFrom(X,_) .
University(Y) :- degreeFrom(_,Y) .
Person(Y) :- hasAlumnus(_,Y) .
TeachingAssistant(X) :- Person(X), teachingAssistantOf(X,Y), Course(Y) .
Chair(X) :- Person(X), headOf(X,Y), Department(Y) .
memberOf(X,Y) :- member(Y,X) .
member(X,Y) :- memberOf(Y,X) .
Course(Y) :- teacherOf(_,Y) .
University(X) :- hasAlumnus(X,_) .
Person(X) :- telephone(X,_) .
Organization(Y) :- subOrganizationOf(_,Y) .
memberOf(X,Y) :- worksFor(X,Y) .
Person(X) :- Employee(X) .
Person(X) :- advisor(X,_) .
Organization(X) :- member(X,_) .
Organization(X) :- Department(X) .
Faculty(X) :- Lecturer(X) .
Person(Y) :- publicationAuthor(_,Y) .
Professor(Y) :- advisor(_,Y) .
Work(X) :- Course(X) .
Professor(X) :- FullProfessor(X) .
degreeFrom(X,Y) :- doctoralDegreeFrom(X,Y) .
TeachingAssistant(X) :- teachingAssistantOf(X,_) .
Person(X) :- undergraduateDegreeFrom(X,_) .
Organization(X) :- University(X) .
Person(X) :- doctoralDegreeFrom(X,_) .
University(Y) :- doctoralDegreeFrom(_,Y) .
Course(Y) :- teachingAssistantOf(_,Y) .
University(Y) :- undergraduateDegreeFrom(_,Y) .
degreeFrom(X,Y) :- mastersDegreeFrom(X,Y) .
Person(X) :- GraduateStudent(X) .
Person(X) :- ResearchAssistant(X) .
Student(X) :- UndergraduateStudent(X) .
degreeFrom(X,Y) :- undergraduateDegreeFrom(X,Y) .
Publication(X) :- publicationAuthor(X,_) .
Person(X) :- mastersDegreeFrom(X,_) .
Organization(X) :- ResearchGroup(X) .
Faculty(X) :- teacherOf(X,_) .
Person(X) :- Chair(X) .
Employee(X) :- Person(X), worksFor(X,Y), Organization(Y) .
Course(X) :- GraduateCourse(X) .
Student(X) :- Person(X), takesCourse(X,Y), Course(Y) .
Person(X) :- TeachingAssistant(X) .
Organization(X) :- subOrganizationOf(X,_) .
Person(X) :- Student(X) .
Person(X) :- emailAddress(X,_) .
subOrganizationOf(X,Z) :- subOrganizationOf(X,Y), subOrganizationOf(Y,Z) .
