Chapter 6 Relational Logic §6.1 Introduction Propositional Logic does a good job of allowing us to talk about relationships among propositions, and it gives us the machinery to derive logical conclusions based on these relationships. Suppose, for example, we believe that, if Jack knows Jill, then Jill knows Jack. Suppose we also believe that Jack knows Jill. From these two facts, we can conclude that Jill knows Jack using a simple application of Modus Ponens. Unfortunately, when we want to say things more generally, we find that Propositional Logic is inadequate. Suppose, for example, that we wanted to say in general that, if one person knows a second person, then the second person knows the first. Here, Propositional Logic is inadequate; it gives us no way of encoding this more general belief. Relational Logic solves this problem by providing a finer grain of representation. In particular, it provides us with a way of talking about individual objects and their interrelationships. It allows us to assert the existence of objects with a given relationship and allows us to talk about all objects having a given relationship and to apply those facts to specific cases. From a representational perspective, Relational Logic is more intuitive than Propositional Logic. Unfortunately, for beginners, the details are a little more complicated; and so we proceed more slowly than before. §6.2 Syntax The vocabulary of Relational Logic is slightly different from that of Propositional Logic. There are no logical constants; and, in their place, we have two new classes of words - variables and constants. By convention, variables begin with letters from the end of the alphabet, viz. u, v, w, x, y, z. By convention, all constants begin with either alphabetic letters (other than u, v, w, x, y, z), mathematical characters (+, -, etc.), or digits. Constants are further subdivided into object constants, function constants, and relation constants. Each function constant or relation constant has an associated positive integer, called its arity, which determines how many arguments it accepts. Note that there is no inherent syntactic distinction between object constants, function constants, and relation constants. The type of each such word is determined by its usage or, in some cases, in an informal vocabulary specification. As we shall see, function constants and relation constants are used in forming complex expressions by combining them with an appropriate number of "arguments". Accordingly, each function and relation constant has an associated arity, i.e. a number indicating the number of arguments to which that function or relation can be applied. A function or relation constant that can applied to a single argument is said to be unary; one that applies to two arguments is said to be binary; more generally, a function or relation constant that applies to n arguments is said to be n-ary. 1 A functional term is an expression formed from an n-ary function constant and n terms enclosed in parentheses and separated by commas. For example, if f is a function constant with arity 2 and if a and b are terms, then f(a,b) is a functional term. Functional terms can occur inside of other functional terms. For example, if a and b are object constants, if f is a function constant with arity 2, and if g is a function constant with arity 1, then the expression f(g(a),b) is a properly formed functional term, as is the expression g(f(a,b)). We use the word term to refer to any variable, object constant, or functional term. As we shall see, terms refer to objects and, as such, are analogous to noun phrases of natural language. There are two types of sentences in Relational Logic, viz. relational sentences (the analog of propositional constants in Propositional Logic) and logical sentences (the analog of logical sentences in Propositional Logic). A relational sentence is an expression formed from an n-ary relation constant and an appropriate number of terms. For example, if r is a relation constant with arity 3 and if a, b, and c are terms, then the expression shown below is a relational sentence. r(a,b,c) Remember that the arguments in a relational sentence can be terms of any sort, not just object constants. Variables and functional terms are equally acceptable. Logical sentences are defined as in Propositional Logic. There are negations, conjunctions, disjunctions, implications, reductions, and equivalences. The syntax is exactly the same, except, of course, the elementary components are relational sentences rather than logical constants. A sentence is ground if and only if it contains no variables. For example, the sentence human(joe) is ground, whereas the sentence human(x) is not. §6.3 Semantics The Herbrand universe,… The Herbrand base is the set of all ground, atomic sentences in the language. A dataset is an arbitrary subset of the Herbrand base. {clear(a),clear(d),table(c),table(d), on(a,b),on(b,c),on(d,e),stack(a,b,c)} Intuitively, a dataset is the set of all data that are true in the world being considered. If a datum is not included in a dataset, it is assumed to be false in that dataset. A ground atomic sentence is true in a dataset (written ) if and only if is a member of . Model: 2 True: clear(a) clear(d) Not True: clear(b) clear(c) clear(e) A negation is true if and only if its target is false. A conjunction is true if and only if every conjunct is true. A disjunction is true if and only if some disjunct is true. An implication is true if and only if the antecedent is false or the consequent is true. A reduction is true if and only if the antecedent is false or the consequent is true. An equivalence is true if and only if the arguments are either both false or both true. The preceding definitions apply to ground sentences only, i.e. those with no variables. The semantics of non-ground sentences is based on the instances of those sentences. An instance of a sentence relative to a model is a sentence obtained by consistently substituting an object constant from the model’s universe of discourse for each free variable in the sentence. p(x,y) q(x,b,z) p(a,a) q(a,b,b) A sentence is valid if and only if every dataset satisfies it; otherwise, it is falsifiable. A sentence is unsatisfiable if and only if no dataset satisfies it; otherwise, it is satisfiable. A set of premises logically entails a conclusion (written ) if and only if every dataset that satisfies the premises also satisfies the conclusion (i.e. implies, for all ). Exercises 1. Syntax Test. Assume that red, green, jim, and molly are object constants. Assume that color is a unary function constant. And assume that p is a unary relation constant and parent is a binary relation constant. Under these assumptions, say whether each of the following expressions is a legal sentence in Relational Logic. (a) (b) (c) (d) (e) (f) (g) (h) parent(red,green) color(jim) color(blue,molly) color(molly)=red green parent(molly,molly) parent(molly) parent(molly,z) x(jim,molly) x(molly,jim) 3 2. Translation. Use the following vocabulary to express the information in the sentences below. male(x) means that the object denoted by x is male. female(x) means that x is female. vegetarian(x) means that x is a vegetarian. butcher(x) means that x is a butcher. (a) No man is both a butcher and a vegetarian. (b) All men except butchers like vegetarians. (c) The only vegetarian butchers are women. (d) No man likes a woman who is a vegetarian. (e) No woman likes a man who does not like all vegetarians. 3. Lists. Write the axioms defining the function reverse, which takes a list as argument and returns, as value, the reverse of the list supplied as its argument. 4. Map coloring. Consider the problem of coloring the following map, using only four colors, such that no two adjacent regions share the same color. 6 3 4 2 5 1 This problem can be set up as a Relational Logic problem. Write down the database and the query. 4