我有一个规则,我必须检查一个部门工作的人是否也为其大学和大学工作。示例知识库如下:
university(xxx). /*the university*/
col(scienceAndMath,xxx). /*the college of the university*/
dept_col(biology,scienceAndMath). /*the department of the college*/
dept_faculty(michael,biology). /*the faculty member of the department*/
我必须制定一条规则,即works_for(X,Y)
来检查为某个部门工作的人,也适用于其大学和大学。我试图以下列方式做到这一点,但无济于事。
works_for(X,Y):-dept_faculty(X,Y).
works_for(X,Y):-dept_col(works_for(X,Y),Y).
/*also tried works_for(X,Y):-dept_col(dept_faculty(X,Y),Y)./*
例如,对于查询works_for(michael,X).
,结果应如下:
X = biology
X = scienceAndMath
如何将事实作为参数传递给另一个事实?目前,查询的答案如下:
X = biology
false.