0% found this document useful (0 votes)
22 views7 pages

AI Assignment

The document provides an overview of first-order logic (FOL), distinguishing it from formal and natural languages, and detailing its syntax, semantics, and applications. It explains key concepts such as terms, atomic and complex sentences, quantifiers, and the TELL/ASK interface for knowledge bases. Examples illustrate the use of FOL in representing knowledge and reasoning in mathematics and artificial intelligence.

Uploaded by

Solomon Asefa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views7 pages

AI Assignment

The document provides an overview of first-order logic (FOL), distinguishing it from formal and natural languages, and detailing its syntax, semantics, and applications. It explains key concepts such as terms, atomic and complex sentences, quantifiers, and the TELL/ASK interface for knowledge bases. Examples illustrate the use of FOL in representing knowledge and reasoning in mathematics and artificial intelligence.

Uploaded by

Solomon Asefa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Faculty of Engineering and Technology

Department of Computer Science

Artificial Intelligence

Assignment III

Name: Solomon Asefa

Id: UU83394R

Section: N4

Submitted to: Mr. Getahun

Submission Date: 01/01/2024


FIRST-ORDER LOGIC

Formal, natural and FO languages are different types of languages that have different characteristics and
purposes. Here is a brief overview of each one:
Formal Languages
Definition: Formal languages are intentionally designed by people for specific purposes, such as
mathematics, logic, programming, etc.
Precise Rules: These languages have strict and well-defined rules of syntax (structure) and semantics
(meaning).
Lack of Ambiguity: Formal languages are not ambiguous or context-dependent, meaning that their
expressions have clear interpretations.
Examples: Propositional logic, first-order logic, regular expressions are examples of formal languages used
in various domains.
Propositional logic: a simple logic that uses symbols to represent propositions (statements that can be true or false) and
connectives (operators that combine propositions). For example, p ∧ q means “p and q are both true”. Propositional
logic can be used to reason about the truth or falsity of complex statements based on simpler ones.
➢ Ontological Commitment: Assumes facts that hold or do not hold in the world.
➢ Epistemological Commitment: Represents facts with three possible states: true, false, or unknown.
First-order logic: a more expressive logic that extends propositional logic by introducing quantifiers (symbols that
express how many or which objects satisfy a property) and predicates (symbols that represent properties or relations
of objects). For example, ∀x P(x) means “for all x, P(x) is true”, where x is a variable and P is a predicate. First-order
logic can be used to model natural languages and mathematical theories.
➢ Ontological Commitment: Assumes a world consisting of objects with relations among them.
➢ Epistemological Commitment: Represents facts and allows beliefs about objects and relations with three
possible states.
Regular expressions: a notation that describes patterns of characters or symbols. For example, [a-z]+ means
“one or more lowercase letters”. Regular expressions can be used to search, manipulate, or validate strings,
such as text, passwords, or URLs.
Natural Languages
Definition: Natural languages are languages spoken by people, like English, Spanish, French, etc., that
have evolved naturally over time.
Complex Rules: They have intricated and flexible rules of syntax (sentence structure) and semantics
(meaning of words and sentences).
Ambiguity and Context-Dependency: Natural languages often contain ambiguity and depend on context
for precise interpretation.
Examples: English, Spanish, French are examples of natural languages used for everyday communication
and expression.
First-Order (FO) Languages
Subset of Formal Languages: FO languages are a subset of formal languages that utilize first-order logic
as their foundational framework.
Components of First-Order Logic: First-order logic incorporates objects, relations, and functions as its
fundamental components.
Expressiveness: FO languages are more expressive than propositional logic, enabling representation of
complex relationships.
Applications: Widely used in mathematics and artificial intelligence for modeling and reasoning. They
can also be applied to model aspects of natural languages.
Examples: Prolog, SQL, RDF (Resource Description Framework) are examples of FO languages utilized
in various fields.

First-Order logic Syntax and semantics


In propositional logic, models link proposition symbols to predefined truth values. In contrast, models for
first-order logic involve a more intricate structure, incorporating objects in a domain, relations, functions,
and interpretations.
Objects and Domain:
➢ Models in first-order logic include a domain, which is the set of objects or domain elements.
➢ The domain must be nonempty, ensuring that every possible world contains at least one object.
➢ Example: A model with objects like Richard the Lionheart, King John, left legs, and a crown.
Relations and Functions:
➢ Objects in the model may have various relationships, expressed through relations (sets of tuples)
and functions.
➢ Binary relations, such as brotherhood and "on head," relate pairs of objects.
➢ Unary relations (properties) like "person," "king," and "crown" may also exist.
➢ Unary functions, like "left leg," map objects to specific attributes.
➢ Total functions are required in models, ensuring a value for every input tuple.
Symbols and Interpretations:
➢ Symbols in first-order logic come in three kinds: constant symbols, predicate symbols, and function
symbols.
➢ Uppercase letters typically denote these symbols, each with a specified arity.
➢ Interpretation in a model specifies the link between objects, relations, functions, and logical
symbols.
As a natural language, first-order logic also has two main parts: Syntax and Semantics
Syntax of First-Order logic:
The syntax of FOL determines which collection of symbols is a logical expression in first-order logic.
The basic syntactic elements of first-order logic are symbols. We write statements in short-hand
notation in FOL.
Symbols in first-order logic come in three kinds: constant symbols, predicate symbols, and function
symbols.
Uppercase letters typically denote these symbols, each with a specified arity.
The syntax involves atomic sentences, complex sentences, terms, quantifiers, constants, variables,
predicates, and functions.
First-order logic (like natural language) does not only assume that the world contains facts like propositional
logic but also assumes the following things in the world:
➢ Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
➢ Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation such as: the sister
of, brother of, has color, comes between
➢ Function: Father of, best friend, third inning of, end of, ......
Basic Elements of First-order logic:
Following are the basic elements of FOL syntax:
Constant 1, 2, A, John, Mumbai, cat,....
Variables x, y, z, a, b,....
Predicates Brother, Father, >,....
Function sqrt, LeftLegOf, ....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃

Terms
A term is a way of talking about something. Sometimes we use a name for something, like John. Sometimes
we use a description for something, like “King John’s left leg”. We can use functions to make descriptions,
like LeftLeg(John). A function is like a word that takes other words as inputs and makes a new word as
output. A term can be a name, a function, or a function with other terms inside it.
A term means something in a model. A model is a way of imagining how things are. A model has objects,
like people and legs. A model also has relations and functions, like brotherhood and left leg. A function in
a model is like a rule that tells us what object we get when we give it some objects. For example, the left
leg function tells us what leg we get when we give it a person. A term in a model means the object that we
get when we use the function and the objects in the model. For example, LeftLeg(John) in a model means
the left leg of King John in that model.
Atomic sentences
Atomic sentences are the most basic sentences of first-order logic. These sentences are formed from a
predicate symbol followed by a parenthesis with a sequence of terms.
➢ We can represent atomic sentences as Predicate (term1, term2, ......, term n).
➢ Example: Ravi and Ajay are brothers: => Brothers (Ravi, Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences
➢ Complex sentences are made by combining atomic sentences using connectives.
First-order logic statements can be divided into two parts:
➢ Subject: Subject is the main part of the statement.
➢ Predicate: A predicate can be defined as a relation, which binds two atoms together in a statement.
Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of the
statement and second part "is an integer," is known as a predicate.

Quantifiers in First-order logic


A quantifier is a language element which generates quantification, and quantification specifies the quantity
of specimen in the universe of discourse.
These are the symbols that permit to determine or identify the range and scope of the variable in the logical
expression. There are two types of quantifiers:
a. Universal Quantifier, (for all, everyone, everything)
b. Existential quantifier, (for some, at least one).
Universal Quantifier
Universal quantifier is a symbol of logical representation, which specifies that the statement within its range
is true for everything or every instance of a particular thing.
The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.
Note: In universal quantifier we use implication "→".
If x is a variable, then ∀x is read as: For all x or For each x or For every x.
Example:
All man drink coffee
Let a variable x which refers to a cat so all x can be represented in UOD as below:
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who drink coffee.

Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true
for at least one instance of something.
It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a predicate
variable then it is called an existential quantifier.
Note: In Existential quantifier we always use AND or Conjunction symbol (∧).
➢ If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as: There exists a 'x.'
or For some 'x.' or For at least one 'x.'
Example:
Some boys are intelligent.
∃x: boys(x) ∧ intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.

Using First-Order Logic


In this section, we delve into practical applications of first-order logic, starting with an overview of the
TELL/ASK interface for knowledge bases. The concept of a domain, representing a specific part of the
world, serves as the foundation for expressing knowledge.
Assertions and Queries in First-Order Logic
Assertions: Sentences are added to a knowledge base using the TELL command, like propositional logic.
These added sentences, termed assertions, convey knowledge about the domain. For instance, asserting
that John is a king, Richard is a person, and all kings are persons is represented as follows:
TELL (KB, King (John)).
TELL (KB, Person (Richard)).
TELL (KB, ∀ x King(x) ⇒ Person(x)).

Queries: Questions about the knowledge base are posed using the ASK command. These queries, also
called goals, seek affirmation based on logical entailment. For example:
ASK (KB, King(John))

If true, the query returns affirmative. Quantified queries, like asking if there exists a person, are also
possible:
ASK (KB, ∃ x Person(x)) .

However, for a more detailed exploration, the ASKVARS function is utilized. For instance:
ASKVARS (KB, Person(x))

This function returns a stream of answers or binding lists, providing specific values that make the query
true. Notably, ASKVARS is generally reserved for Horn clause-based knowledge bases.

You might also like