Artificial Intelligence - First-order Logic



Propositional logic deals with declarative statements that are either true or false. However, it has a significant disadvantage it cannot state relationships between objects or convey general statements quickly.

For example, consider the following sentence. "The sky is hot" propositional logic only decides that a statement is true or false, but it cannot explain the relationship between the sun and heat. Similarly, if we want to declare that "All students in a class like mathematics," propositional logic would require a different statement for each student, which is impractical for huge collections of things.

This is where First-Order Logic comes in. FOL expands propositional logic by including quantifiers and variables, allowing us to construct such assertions more efficiently.

First-Order Logic in Artificial intelligence

First-Order Logic, more popularly known as Predicate Logic, or First-Order Predicate Logic for short, is an extension of Propositional Logic. Unlike propositional logic which only tells that a statement is either true or false, First-Order Logic allows us to define relationship between objects, general rules, and quantified statements.

Key components of First-Order Logic

The fundamental components of First-Order Logic (FOL), which helps in the systematic representation of relationships, objects, and logical propositions, are as follows −

  • Constants are different objects or constant values that exist inside given domain. For example − Krish, Bob, 5, Apple.

  • Variables are symbols that can take several values inside a particular domain. Commonly used symbols for variables are x,y,z. If the domain consists of students, then x could represent any student in the class.

  • Predicates are statements that describe properties of objects or their relationships. They accept at least one parameter, which may be a constant or a variable. For example − Father(John, Robert). Here father is predicate which tells the relation between John and Robert.

  • Functions map elements to distinct values. They take arguments in the form of input elements and return a single value as output. For example − Age(Alice) = 25 → means "Alice's age is 25."

  • Quantifiers tell whether a sentence is true for all objects in the domain or just one. For example − xLikes(x,Math) → "All students like Mathematics." and xLikes(x,Math) → "There exists at least one student who likes Mathematics."

  • Logical connectives enable to logically combine numerous statements or propositions. They allow complicated statements to be constructed from simpler ones. For example − CompletesTraining(x)→EligibleForPromotion(x). If an employee x completes the required training, then they automatically become eligible for a promotion.

Logical Components in Formal Logic

The following table lists the constants, variables, functions, predicates, quantifiers, and logical connectives which are used to build formal logic −

Components Examples
Constants 1, 5, Apple, Bob, India
Variables x, y, z, a, b
Predicates Father, Teacher, Brother
Functions sqrt, LeftLegOf, AgeOf, add(x, y)
Quantifiers ∀ (for all), ∃ (there exists)
Connectives ∧ (and), ∨ (or), ¬ (not), → (implies), ↔ (if and only if)

Syntax and Semantics of First-Order Logic (FOL)

The syntax of FOL describes the form of valid assertions by employing constants, variables, predicates, functions, quantifiers, and logical connectives. Statements are composed of words (which represent objects) and atomic formulae (which convey facts).

The semantics of first-order logic (FOL) define the meaning of assertions by interpreting predicates and words throughout a domain. An interpretation gives real-world meaning to objects and relationships.

Example

The following example demonstrates how syntax and semantics are applied in First-Order Logic (FOL) to represent a real-world statement −

  • Consider a statement "Every customer who makes a purchase receives an invoice".

  • The FOL representation of the statement using syntax and semantics is as follows x(Customer(x)Purchases(x,Product)→ReceivesInvoice(x))

  • Thus, syntax defines the structure, and semantics give it meaning.

Quantifiers in First-Order Logic

Quantifiers in First-Order Logic define the number of objects in the domain that meet a specific condition. They allow us to communicate statements about all or some objects in a systematic manner.

Types of Quantifiers in FOL

First-Order Logic has two main types of quantifiers −

  • Universal Quantifier ( ) "For All"

  • Existential Quantifier ( ) "There Exists"

Universal Quantifier ( ): The universal quantifier (x) is used to state that a statement applies to all items in the domain. It is used to convey general truths or rules.

For example, let the statement be "All employees in a company must follow the rules." By using FOL the representation would be x(Employee(x)→FollowsRules(x)) meaning "For every x, if x is an employee, then x follows the rules."

Existential Quantifier ( ): The existential quantifier "x" indicates that at least one object in the domain meets the provided condition.It is used to indicate that something exists without listing all instances.

For example, let the statement be "There is at least one employee who received a promotion. The FOL representation would be "x(Employee(x)ReceivedPromotion(x)) meaning "There exists some x, such that x is an employee and x received a promotion."

Sentences in First-Order Logic

In First-Order Logic (FOL), sentences are used to represent facts and relationships. These sentences can be classified into atomic sentences and complex sentences, as explained below −

Atomic Sentences

An atomic sentence is the most basic form of a statement in First-Order Logic. It consists of a predicate and arguments, which can be either constants or variables. An atomic statement asserts a fact about things without using logical connectives.

Structure of Atomic Sentences: Predicate(Argument 1,Argument 2,...,Argument n)

where −

  • The predicate represents a property or relationship.

  • The arguments represent objects (constants or variables).

Example

The following example demonstrate the use of atomic sentences in First-Order Logic to represent facts and relationships −

  • Teacher(John, Mathematics) This atomic sentence states that John is a teacher of Mathematics.

Complex sentence

Two or more atomic statements connected by logical connectives like AND (), OR (), NOT (¬), Implies (→), and Bi-conditional () create a complex sentence. These sentences allow us to express more complex logical statements.

Example

The following examples demonstrate the use of complex sentences in First-Order Logic to represent facts and relationships −

  • (y Teacher(y) Teaches(y, Math)) "There exists at least one teacher who teaches Mathematics."

  • (x Customer(x) → Buys(x, TutorialsPointCourses)) "For all customers, if x is a customer, then x buys courses from Tutorials Point."

  • (y Employee(y) WorksFor(y, TutorialsPoint)) "There exists at least one employee who works for Tutorials Point."

Free and Bound Variables in First-Order Logic

Variables in FOL can be either free or bounded depending on the fact that a variable is controlled by any quantifier.

Free Variable

A free variable cannot be quantified using or . It can hold any value but has no fixed meaning unless assigned.

Example

Let us consider a statement "y is the price of a product."

  • The FOL representation for the above statement will be P(y) (where P(y) means y is the price of a product).

  • Here, y is free because we don't specify which products price we are referring to.

Bound Variable

A bound variable is within the scope of a quantifier and is dependent on it, so its value is limited by the quantifier.

Example

Let the sentence be "There exists a product whose price is less than $10."

  • The FOL representation of the above sentence is yP(y) (where P(y) means y is less than $10).

  • Here, the existential quantifier () constrains the variable y, indicating that it is applicable to a specific product in the context.

Challenges and limitations of First Order Logic

When utilizing First-Order Logic (FOL) for knowledge representation and reasoning, several key challenges and limitations arise, as follows −

  • Challenges in Handling Uncertainty: FOL requires facts to be definitively true or false, making it difficult to represent probabilistic or uncertain information.

  • High Computational Demands: When dealing with extensive knowledge bases, logical inference in FOL can become slow and resource-intensive.

  • Limited Expressive Power: Concepts from the real world that involve fuzzy or probabilistic logic, such as "most people" or "approximately," are difficult for FOL to articulate.

  • Rigid Rule-Based Framework: The necessity for facts and rules to be explicitly defined results in a structure that is inflexible and struggles to incorporate new information.

  • Common-Sense thinking Difficulty: FOL finds it difficult to manage common sense thinking that incorporates assumptions, exceptions, or insufficient information.

Advertisements