PAL Constraint Statements

A PAL statement is composed of a set of embedded predicate and functional expressions that involve variables ranging over a set of values (range definitions), and that ultimately return true or false on each particular instantiation of variables.

A PAL constraint statement consists of a sequence of sentences linked by logical connectives among the following: <=> (equivalent), => ("if"), and, or, not. To write those sentences, PAL supports a number of predefined predicates and functions, that can be used in constraint statements to test or compute properties of variables. In addition, any slot in a knowledge base can be used directly as a function or a unary predicate in PAL statements. Finally, all variables that appear in a constraint statement must be quantified, either with the universal quantifier (forall) or with the existential quantifier (exists).

Note: When a constraint is attached to a class, there is a default universal quantifier (forall) if no other quantifier is present. However, in this case, the The Query Response Pane for Constraints will not show violating instances, and in general this is not good practice.

PAL predicates can be listed as:

PAL functions can be listed as:

 

Below are a few example constraints from the newspaper project.

A simple constraint that states that all articles should be indexed with more than two keywords:

PAL Constraint Comments
(defrange ?article :FRAME Article) This constraint concerns all instances of the Article class.
(forall ?article
           (> (number-of-slot-values keywords ?article) 2))

 

"For all articles, the number of values for the slot keywords should be greater than 2."

Note that this constraint is equivalent to setting the minimum cardinality facet to 2 for the keywords slot attachment.

 

Similarly, the above example constraint that states that editors should be paid more than the employees for whom they are responsible:

PAL Constraint Comments
(defrange ?editor :FRAME Editor)
(defrange ?employee :FRAME Employee responsible_for)
This constraint concerns all instances of the Editor class, and instances of the Employee class that are values for the slot responsible_for.
(forall ?editor (forall ?employee
    (=> (and
        (responsible_for ?editor ?employee)
        (own-slot-not-null salary ?editor)
        (own-slot-not-null salary ?employee))
    (> (salary ?editor) (salary ?employee)))))

 

 

"For all editors, and for all employees for whom an editor is responsible (see range definition above), if the editor in question is responsible for the employee in question and both the salaries of this editor and this employee are not empty, this editor's salary should be greater than this employee's salary."

The slot responsible_for is used as a predicate, to test whether the employee in question is under the responsibility of the editor in question.

The slot salary is used as a function, to return the value of the employee's and editor's salary.

 

A constraint that states that the section in which an article is published is determined by the section on which the author of this article works (i.e., on the Article class, the slot containing_section is constrained by the slot article_author):

PAL Constraint Comments
(defrange ?article :FRAME Article)
(defrange ?editor :FRAME Editor)
The constraint concerns all instances of the Article class, and any instance of the Editor class.
(forall ?article
          (=> (instance-of (article_author ?article) Person)
                  (exists ?editor
                             (and (or (article_author ?article ?editor)                                              (responsible_for ?editor (article_author ?article)))
                                     (sections ?editor (containing_section ?article))))))

 

 

 

 

 

 

 

"For all articles, if the author of an article is a person, then there exists an editor, who is either this author or the editor responsible for this author. The section that contains this article is a section managed by this editor."

The slots article_author and responsible_for and sections are used as predicates, to test respectively whether the author of the article in question is the editor in question, whether the editor in question is responsible for the author of the article in question, and whether the section that contains the article in question is one of the sections managed by the editor in question.

The slots article_author, and containing_section are used as functions, to return the value of the author and section of the article in question.

 

A constraint that states that the global variable %number_of_pages is positive, wherever it happens to be used in the knowledge base:

PAL Constraint Comments
(defrange %number_of_pages :INTEGER number_of_pages) This global variable ranges over all integers that are values for the slot number_of_pages.
(forall %number_of_pages
    (> %number_of_pages 0))

 

"All values of the number_of_pages slot should be greater than 0."

Note that this constraint is equivalent to setting the minimum-value facet of the number_of_pages top-level slot to 0.

 


The PAL Language and Frames/PAL Constraint Statements

Next: PAL Query Statements

PAL Table of Contents