% % This example illustrates the use of set terms and set generators % within LDL rules. % export co_authors(Author, Title). export co_authors($Author, Title). export papers_by_subject(Subject, Titles). export papers_by_author($Author, Titles). % % co_authors(CoAuthor, Title) % Title is the title of a paper for which CoAuthor was one of the % authors. Use of 'Ullman' in the paper relation ensures that we will return % only those authors who co-wrote papers with 'Ullman'. Furthermore, we are only % interested in papers on the subject of recursion. The inequality ensures % that we do not return papers written without a co-author (sole author would % be 'Ullman'). Since the cardinality of the set of authors used is three, we % will explore all possibilities within the database for papers written by % two or three authors. % co_authors(CoAuthor1, Title) <- paper({ 'Ullman', CoAuthor1, _ }, Title, SubjectCode), subject(SubjectCode, recursion), CoAuthor1 ~= 'Ullman'. % % papers_by_subject(Subject, Titles) % Titles is the set of titles of papers pertaining to Subject. Set % grouping is used to group the papers in the database based on the subject % of the paper. % papers_by_subject(Subject,