subject(mathematics).
subject(physics).
subject(computer_science).
subject(economics).
subject(english).

student(john).
student(lisa).
student(alex).
student(sarah).
student(mike).
student(frank).
student(tom).
student(ann).
student(tim).
student(dunk).

professor(prof_doe).
professor(prof_walker).
professor(prof_smith).
professor(prof_jones).
professor(prof_brown).
professor(prof_adams).
professor(prof_davis).
professor(prof_johnson).

teaches(prof_smith, mathematics).
teaches(prof_doe, mathematics).
teaches(prof_jones, physics).
teaches(prof_brown, computer_science).
teaches(prof_adams, economics).
teaches(prof_walker, economics).
teaches(prof_davis, english).

enrolled(john, mathematics).
enrolled(john, computer_science).
enrolled(lisa, computer_science).
enrolled(alex, mathematics).
enrolled(alex, physics).
enrolled(sarah, mathematics).
enrolled(sarah, economics).
enrolled(mike, mathematics).
enrolled(frank, english).
enrolled(tom, computer_science).
enrolled(tom, economics).
enrolled(ann, english).

has_subject(Student, Subject) :- enrolled(Student, Subject).
has_student(Professor, Student) :- teaches(Professor, Subject), enrolled(Student, Subject).
teaches_subject(Professor, Subject) :- teaches(Professor, Subject).
teaches_subject(Professor, Subject) :- has_student(Professor, Student), has_subject(Student, Subject).
has_professor(Student, Professor) :- enrolled(Student, Subject), teaches(Professor, Subject).
enrolled_in_subject(Student, Subject) :- enrolled(Student, Subject).
enrolled_in_subject(Student, Subject) :- has_professor(Student, Professor), teaches(Professor, Subject).

subject(Subject).
enrolled(Student, computer_science).
enrolled(Student,Subject).
teaches(Professor, mathematics).
teaches(prof_jones, Subject).
has_professor(john, Professor).
enrolled(Student, mathematics), enrolled(Student, computer_science).
student(Student), not(enrolled(Student, _)).