Predicate Logic, Quantifiers, and Foundations of Logic Programming
Mathematical Sets and Domain Foundations
Predicate logic relies heavily on specifying the collections of objects over which variables range. Standard notations for fundamental numerical sets include:
- Natural numbers:
- Integer numbers:
- Rational numbers:
- Real numbers:
- Complex numbers:
Fundamentals of Predicate Logic
Statements such as , , and contain symbols such as , , and that denote relations between variables and values:
- In , the relation holds between and .
- In , the relations and hold between , , and .
- In , the relations hold between , , and .
These relations may either hold or fail to hold depending on the specific values assigned to the variables , , and .
A predicate is a property that is affirmed or denied about the subject of a statement. In formal logic, the subject is referred to as the variable or argument:
- In the statement " is greater than 3", the component is the subject.
- The phrase "is greater than 3" is the predicate.
A statement containing one or more variables is a predicate. A predicate is not a proposition on its own because it lacks a definitive truth value. However, if values are assigned to all variables within a predicate, the resulting statement becomes a proposition:
- The statement "" is a predicate where denotes any real number ().
- Substituting the value for yields the proposition "", which has a truth value of True ().
- Substituting the value for yields the proposition "", which has a truth value of False ().
Propositional Functions and Arity
A propositional function is a sentence expressed in a manner that would assume a truth value of either true or false, except that it contains one or more variables that are not defined or specified, leaving the statement undetermined.
To symbolize a statement like " is greater than 3" in predicate logic:
- Introduce a functional symbol for the predicate, such as .
- Place the subject as an argument to the functional symbol, written as .
The statement represents the value of the propositional function at . In this notation:
- is a statement.
- is the predicate or propositional function.
- is the argument.
Predicates are classified by their arity, which is the number of arguments they accept:
- Unary predicate (arity 1): Accepts one argument, such as .
- Binary predicate (arity 2): Accepts two arguments, such as .
- Ternary predicate (arity 3): Accepts three arguments, such as .
- -ary predicate (arity ): Accepts arguments, denoted or .
A statement of the form is the value of the propositional symbol evaluated at the -tuple . Conceptually, a propositional function:
- Takes one or more arguments.
- Expresses a predicate involving those arguments.
- Evaluates to true or false once values are assigned to all its arguments, thereby becoming a proposition.
Consider the ternary propositional function denoting :
- For , asserts (), which is True.
- For , asserts (), which is False.
- Similarly, asserts (), which is False.
- There are infinitely many triples that make true, corresponding to the infinite number of right triangles.
Universe of Discourse
When evaluating a statement such as , assigning an entity like "blue" to is meaningless. The universe of discourse (also known as the domain of discourse, or simply the domain) is the set of all objects that can sensibly be assigned to a variable in a propositional function.
For example, given the propositional function:
\text{EnrolledCSE235}(x) = \text{`x is enrolled in CSE235'}
The universe of discourse for comprises all students (specifically university students eligible for enrollment).
In multivariate functions, each argument in an -tuple may draw from a distinct universe of discourse. Consider the 4-ary predicate:
P(r, g, b, c) = \text{`The RGB values of the color c is $(r, g, b)'}
- The universes of discourse for , , and are the set of valid color channel intensity integers, .
- The universe of discourse for is the set of color names.
- Evaluating yields True, as pure red is represented by RGB coordinates .
- Evaluating yields False, as corresponds to blue, not green.
Quantifiers in Predicate Calculus
A predicate statement containing variables can be transformed into a proposition with a definitive truth value through two primary methods:
- Assigning concrete values from the universe of discourse to every variable.
- Quantification.
Quantification expresses the extent to which a predicate is true over a range of elements. The formal branch of logic dealing with predicates and quantifiers is termed the predicate calculus (or First-Order Logic).
While natural languages express quantification using words like all, some, many, none, and few, predicate calculus centers on two fundamental types:
- Universal Quantification: Asserts that a predicate is true for every element in the domain.
- Existential Quantification: Asserts that a predicate is true for at least one element in the domain.
The Universal Quantifier
The universal quantification of a predicate is the proposition:
" is true for all values of in the universe of discourse."
This is denoted by the universal quantifier symbol :
This expression is read as "for all , " or "for every , ".
If the universe of discourse is finite and consists of elements , the universal quantification is equivalent to the conjunction of the propositions evaluated at every element:
A counterexample is any element in the universe of discourse for which is false. A single counterexample is sufficient to disprove a universally quantified statement.
Application Examples of Universal Quantification
Let be " must take a discrete mathematics course" and be " is a CS student", where the universe of discourse consists of all computer science students:
- "Every CS student must take a discrete mathematics course":
- "Everybody must take a discrete mathematics course or be a CS student":
- "Everybody must take a discrete mathematics course and be a CS student":
Expressing the statement "for every and every , " over the universe of discourse of integers :
where denotes .
Evaluating Universal Quantifications
- Let be "" with the domain of all real numbers . The statement is false because provides a counterexample where ("") is false.
- Let be "" over the universe of discourse of all integers . The statement is false because is a counterexample: , which is not strictly greater than .
- Let be "" over the domain of positive integers not exceeding 4 (i.e., ). The universal quantification corresponds to the conjunction:
Evaluating each:
- (True)
- (True)
- (True)
- (False) Because is false, is False.
The Existential Quantifier
The existential quantification of a predicate is the proposition:
"There exists a value in the universe of discourse such that is true."
This is denoted by the existential quantifier symbol :
This expression is read as "there exists such that " or "there is at least one such that ".
If the universe of discourse is finite and consists of elements , the existential quantification is equivalent to the disjunction of the propositions evaluated at every element:
The statement is false if and only if there is no element in the domain for which is true—that is, is false for every element in the domain.
Application Examples of Existential Quantification
- Let denote "". The expression asserts that there exists some pair and whose sum equals 5. This is true over the integers , rationals , or reals .
- Expressing "there exists a real solution to " where are fixed constants: The roots of the equation are given by the quadratic formula: Let be the predicate defining the solution. Over the domain of real numbers , is false whenever the discriminant is negative (). To ensure is unconditionally true for any quadratic with non-zero , the universe of discourse must be extended to the complex numbers .
- Expressing "There exists an such that ": Setting as "", this is transcribed as:
- Let denote "" over the domain of real numbers . The quantification is True because there exists at least one value (for example, ) for which the condition holds.
- Let denote "" over the domain of real numbers . The quantification is False because no real number satisfies the equation, making false for every element in the domain.
Truth Values of Quantified Statements
| Statement | True When… | False When… |
|---|---|---|
| is true for every | There is an for which is false | |
| There is an for which is true | is false for every |
Nested and Mixed Quantifiers
Existential and universal quantifiers can be combined to quantify multi-variable predicates. For instance, is a valid quantified expression.
When evaluating mixed quantifiers:
- Expressions must be parsed strictly from left to right.
- The order of different quantifiers is critical and generally non-commutative:
Consider the predicate , signifying " loves ":
- : "Everybody loves somebody."
- : "There is someone loved by everyone."
These statements carry entirely different meanings. The presence of an individual loved by everyone logically implies that everyone loves someone, but the converse is not true:
However, consecutive quantifiers of the same type commute freely without altering the logical meaning:
Truth Values of Mixed Quantifiers
| Statement | True When… | False When… |
|---|---|---|
| is true for every pair | There is at least one pair for which is false | |
| For every , there is a for which is true | There is an for which is false for every | |
| There is an for which is true for every | For every , there is a for which is false | |
| There is at least one pair for which is true | is false for every pair |
Mathematical Examples of Nested Quantifiers
- Infinitude of integers: Over the universe of discourse of integers , stating that there is an infinite number of integers is formulated using the predicate as "":
- Commutative law of addition for : For every pair of real numbers , the identity holds. Letting denote :
- Multiplicative inverse for non-zero reals (): For every non-zero real number , there exists a real number such that :
- Non-commutativity of subtraction over : The proposition asserting commutativity of subtraction is: This is a false mathematical statement over .
- Additive and multiplicative identity elements: The statement "There is a number such that when it is added to any number, the result is that number, and if it is multiplied by any number, the result is " is formalized over domains , , , or . Letting be and be : (This holds true for ).
Variable Binding and Scope
A variable in predicate logic can be categorized depending on its association with a quantifier:
- Bound Variable: A variable on which a quantifier is applied.
- Free Variable: A variable occurring in a predicate expression that is not governed by any quantifier.
In the expression , both and are bound variables. In the expression , the variable is bound, but the variable is free.
A statement is termed a well-formed formula (WFF) when all of its variables are properly quantified. A propositional function cannot represent a proposition with a truth value until every variable appearing within it is bound.
Scope of Quantifiers
The scope of a quantifier is the set of all variables bound by that specific quantifier. In the expression:
- The scope of the existential quantifier contains and .
- The scope of the universal quantifier contains .
- The bound variables are , , and .
- The free variable is .
- The formula is not a well-formed formula because the variable is free.
Non-Equivalence of Quantifier Distribution
A common misconception is that universal quantification distributes across individual variables:
- On the left-hand side, both and are bound variables, rendering it a fully bound proposition.
- On the right-hand side, is free in the first conjunct , while is free in the second conjunct .
- Because the right-hand side contains free variables, it is not a proposition and cannot be logically equivalent to the left-hand side.
Negation of Quantified Expressions
Negating a quantified expression transforms the quantifier type and shifts the negation inward to the underlying predicate. This represents the quantified extension of De Morgan's Laws.
Consider the proposition: "Every student in your class has taken a course in calculus." Letting denote " has taken a course in calculus" over the domain of students in the class, the statement is:
The negation of this statement is: "It is not the case that every student in your class has taken a course in calculus." This is logically equivalent to "There is a student in your class who has not taken a course in calculus", written as:
De Morgan's Laws for Quantifiers
For any predicate :
When the universe of discourse is finite (), these equivalences reduce directly to standard propositional De Morgan's Laws:
Truth Values of Negated Quantifiers
| Statement | True When… | False When… |
|---|---|---|
| is false for every | There is an for which is true | |
| There is an for which is false | is true for every |
Negation Translation Examples
- Negating "There is an honest politician":
Let denote " is honest" over the domain of all politicians.
The statement is .
Its negation is: In English: "Every politician is dishonest." - Negating "All Americans eat cheeseburgers":
Let denote " eats cheeseburgers" over the domain of all Americans.
The statement is .
Its negation is: In English: "Some American does not eat cheeseburgers" or "There is an American who does not eat cheeseburgers."
Pushing Negations Inward
To negate a nested quantified formula, push the negation operator inward step by step, toggling quantifiers and applying De Morgan's laws to logical connectives:
- Move the negation past the universal quantifier :
- Apply De Morgan's Law for conjunction ():
- Distribute negation through the inner quantifiers:
- Combine the result:
Translating English to Predicate Logic
Translating natural language into logical expressions is essential in mathematics, artificial intelligence, software engineering, and logic programming. Natural language statements should be transcribed using a structured sequence:
- Rephrase the statement to reveal the underlying quantifiers:
"Every student in this class has studied calculus" becomes "For every student in this class, that student has studied calculus." - Introduce explicit variables:
"For every student in this class, has studied calculus." - Define propositional functions:
Let denote " has studied calculus." - Define the domain of discourse:
Domain of = students in this class. - Synthesize the symbolic formula:
Pairing Quantifiers with Connectives
Translating natural language requires matching quantifiers with their appropriate connectives:
- Universal quantifiers () typically pair with implication ():
- : "Every lion is fierce." (True even if the universe contains non-lions, provided all lions are fierce).
- If conjunction is erroneously used, , the statement asserts: "Everyone is a lion and everyone is fierce."
- Existential quantifiers () typically pair with conjunction ():
- : "There is at least one vegan lion."
- If implication is erroneously used, , the expression evaluates to True simply by finding any entity that is not a lion (since False Anything is True), failing to represent the original statement.
Logic Programming with Prolog
Prolog (Programming in Logic) is a declarative programming language grounded in a restricted form of Predicate Logic (predicate calculus / first-order logic). Developed by logicians in the Artificial Intelligence community, it is designed for automated theorem proving and symbolic reasoning.
Structure of a Prolog Program
- Facts: Concrete assertions represented as propositional functions:
student(mia)enrolled(mia, cse235)instructor(patel, cse235)
- Rules: Universal implications with conjunctions defining new relations:
teaches(X, Y) :- instructor(X, Z), enrolled(Y, Z)- In Prolog syntax, the
:-symbol represents reverse implication (), a comma,represents logical conjunction (), and a semicolon;represents logical disjunction (). - The rule above defines that professor
Xteaches studentYif there exists a courseZsuch thatXis the instructor ofZandYis enrolled inZ.
- Queries: Questions evaluated against the defined database of facts and rules. Prolog answers queries by binding variables and applying inference rules to prove theorems:
?enrolled(mia, cse235)?enrolled(X, cse476)?teaches(X, mia)
Prolog Execution Example
Consider the following database of facts:
instructor(chan, math273).
instructor(patel, ee222).
instructor(grossman, cs301).
enrolled(kevin, math273).
enrolled(juana, ee222).
enrolled(juana, cs301).
enrolled(kiko, math273).
enrolled(kiko, cs301).
With the rule:
teaches(P, S) :- instructor(P, C), enrolled(S, C).
Evaluating sample queries:
?enrolled(kevin, math273):
Prolog evaluates this against the fact base and returnsYesbecauseenrolled(kevin, math273)is explicitly defined.?enrolled(X, math273):
Prolog determines all bindings for variableXthat satisfy the goal. It outputs:kevinkiko
?teaches(X, juana):
To find all professorsXwho instruct classes taken by Juana, Prolog evaluatesinstructor(X, C), enrolled(juana, C). Juana is enrolled inee222andcs301. The instructors for these classes arepatelandgrossman. The query outputs:patelgrossman
Advanced Formalization Exercises
Disjunction and Negation Equivalences
Expressing "For all , or ":
Let be "" and be "". The proposition is written as:
Because is equivalent to , the statement can also be expressed as:
Quantifier Order Distinctions
Let denote the predicate "". Comparing two distinct statements:
- "For every number there is a number such that ":
- "There is a number such that, for every number , ":
Over the real numbers , statement (1) is true (for any , choosing satisfies the condition), while statement (2) is false (no single can simultaneously equal for all ).
Theatre Seat Booking Formalization
In a theatre seat reservation specification, let denote the predicate "person has booked seat ":
- (a) Seat has been booked:
- (b) Person has booked a (at least one) seat:
- (c) All the seats are booked:
- (d) No seat is booked by more than one person:
If no seat is booked by multiple individuals, then and cannot both be true unless and denote the identical person:
Arithmetic Property Characterization
Let denote " is a factor of ", where and . Consider the quantified predicate:
When evaluated for a specific integer , the property states that the only positive factors of are and itself. This formula formalizes the mathematical definition of a prime number.