PAL Query Statements

Similarly to a constraint statement, a PAL query statement consists of a sequence of sentences linked by logical connectives (<=>, =>, and, or, not). Sentences are written with the same set of PAL predicates and functions and with slots used directly as functions or unary predicates. Variables used in query statements must be defined within a valid range, similarly to constraint variables. The only way in which query statements differ from constraint statements is that variables are "quantified" with the query quantifiers findall and  find n instead of the universal quantifier forall. Variables can also be quantified with the existential quantifier (exists) inside statements.

Below are a few example queries from the newspaper project.

A query that finds 3 articles that are not authored by persons:

PAL Query Comments
(defrange ?article :FRAME Article) The query concerns all instances of the Article class.
(find 3 ?article
           (not (instance-of (article_author ?article) Person)))

 

 

"Find 3 instances of the class Article which author is not an instance of the class Person."

The slot article_author is used as a function, to return the value of the author of the article in question.

 

A query that finds all employees who are in a team (ie, whose responsible editor is responsible for more than 1 employee):

PAL Query Comments
(defrange ?employee :FRAME Employee responsible_for)
(defrange ?editor :FRAME Editor)
The query concerns all instances of the Employee class that are values for the slot responsible_for and any instance of the Editor class.
(findall ?employee
            (exists ?editor
                       (and (responsible_for ?editor ?employee)
                               (> (number-of-slot-values responsible_for ?editor) 1))))

 

 

 

"Find all the employees such that there exists an editor which is responsible for the employee in question and which number of employees under responsibility is greater than 1."

The slot responsible_for is used as a predicate to test whether the editor in question is responsible for the employee in question.

 

A query that finds all employees who are paid more than their responsible editor:

PAL Query Query in English
(defrange ?employee :FRAME Employee responsible_for)
(defrange ?editor :FRAME Editor)
The query concerns all instances of the Employee class that are values for the slot responsible_for and any instance of the Editor class.
(findall ?employee
           (exists ?editor
                      (and (responsible_for ?editor ?employee)
                              (own-slot-not-null salary ?editor)
                              (own-slot-not-null salary ?employee)
                              (< (salary ?editor) (salary ?employee)))))

 

"Find all the employees such that there exists an editor which is responsible for the employee in question and that editor's salary is lower than the salary of the employee in question, both salaries not being empty."

The slot responsible_for is used as a predicate to test whether the editor in question is responsible for the employee in question. The slot salary is used as a function, to return the value of the employee's and editor's salary.



The PAL Language and Frames/PAL Query Statements

Next: PAL Conceptual Framework

PAL Table of Contents