Attributed Variables in XSB

Abstract The attributed variable data type plays an important role in many extensions to the basic Logic Programming language. It provides a flexible mechanism to implement constraint solvers over different domains in a standard logic programming system. To combine the technique of constraint solving with tabling and build a tabled constraint logic programming system, special work has to be done to handle attributed variables when they are copied into and out of tables. In this paper, we describe the implementation of attributed variables in XSB — a tabled logic programming system. We first introduce the internal representation of attributed variables and the interface between the internal representation and the user defined high level unification handler. Then, as the primary focus of the paper, we describe how the tabling mechanism in XSB can be extended to efficiently handle attributed variables. To save attributed variables in tables, the structure of subgoal table and answer table is modified, and the tabling engine itself requires extension as well.