CS 6795 Semantic Web Techniques

Assignment 1



1) Using the space below, recursively define a unary predicate (relation) evenlength in Prolog, which tests -- without using any (numeric) built-ins -- whether its list input argument Lst has an even length (so that a length predicate applied to input argument Lst would bind its output argument to 0 or 2 or 4 or ...). For readability, use anonymous variables where possible. Hint: First consider the base case(s) of the recursion. Test your predicate definition with at least the predicate calls evenlength([]), evenlength([a]), evenlength([a,b]), evenlength([a,b,c]), and evenlength([a,b,c,d]). In one sentence, below your definition, explain what it does for non-ground calls like evenlength([r,X,b,X]).






2) Consider the following oversimplified proposal of a node-labeled ordered tree for flights starting from a fixed airport, instantiated with leaves for a particular flight:

                       /        |            \
                      /         |              \
             pilots   attendants    dynamic-information
             /     \                        /         |                          \
            /       \                    /            |                            \
  name     name         date        destination                 fare
    |  \            |  \              |              /          \                         \
    |    \          |   \             |             /            \                          \
  first last   first last   8/15    code           airport              730
    |       |       |       |                   /                     |         \
  A.  Rist   B.  Meyrs           /                       |             \
                                           /                                         \
                                       YFC                   city        province
                                                                      |                      |
                                                             Fredericton          NB

Do the missing leaf data for attendants cause any (XML-level) issue?

b) Give a well-formed XML element for the tree using a pretty-print layout.

c) Give a b)-equivalent Prolog term.

d) Write a DTD that defines flights according to the original a)-tree or b)-element without structural generalization (e.g. there are exactly two pilots).

e) Extend the DTD such that one or more subelements for attendants must appear, each specifying a name in a form exactly as for the pilots.

For a) through e), use the space below and attach more sheets of paper as necessary (write on both sides of sheets).


Maintained by Harold Boley