First Order Logic: Artificial Intelligence
First Order Logic: Artificial Intelligence
First Order Logic: Artificial Intelligence
ORDER
LOGIC
ARTIFICIAL INTELLIGENCE
Quantifiers
Limitation of proportional logic
Propositional logic is a formal system that is quite straightforward and useful for
representing basic facts and relationships between them. It's declarative, meaning its
syntax directly represents facts. This logic allows for expressing partial, disjunctive,
and negated information, which isn't always easily done in typical data structures or
databases.
However, its expressiveness is limited. While it's great for representing simple
relationships between facts, it falls short when dealing with more complex relationships
or scenarios found in natural language.
For instance, expressing something like "pits cause breezes in adjacent squares" using
propositional logic would require writing a sentence for each square involved, which
becomes cumbersome and inefficient. Additionally, unlike natural language, the
meaning in propositional logic is fixed and context-independent, whereas in natural
language, meaning can heavily depend on the context in which it's used.
WHY FIRST ORDER
LOGIC?
Propositional logic deals with facts in a more simplistic manner, assuming a world containing
straightforward facts. In contrast, first-order logic, much like natural language, assumes the world
contains:
Objects: These are entities or things, like people, houses, numbers, theories, specific individuals (such
as Ronald McDonald), colors, baseball games, wars, or periods of time (centuries).
Relations: These define properties or relationships between objects. They can be qualities (like "red" or
"round"), or they can describe connections or associations between objects (such as "brother of,"
"bigger than," "inside," "part of," "has color," "occurred after," "owns," "comes between," and so on).
Functions: These denote specific relationships where one object is related to another in a particular way.
They can represent actions or transformations, like "father of," "best friend," "third inning of," "one
more than," "end of," and so forth.
By incorporating these elements, first-order logic becomes more precise and powerful than
propositional logic. It allows for the expression of a wide range of relationships and complexities,
mirroring the way natural language deals with the rich variety of entities, connections, and actions
present in the world.
FIRST ORDER LOGIC
•First-order logic is another way of knowledge representation in
artificial intelligence. It is an extension to propositional logic.
•As a natural language, first-order logic also has two main parts:
• Syntax
• Semantics
Example
"All men are mortal."
"Socrates is a man."
"Therefore, Socrates is mortal."
In first-order logic, we can represent these statements using predicates, quantifiers, and constants. Here's how it can be
written:
Constants:
S represents Socrates.
x represents any individual.
Predicates:
M(x) represents "x is a man."
R(x) represents "x is mortal."
Quantifiers:
∀ means "for all" (universal quantifier).
∃ means "there exists" (existential quantifier).
Using these elements, we can express the given statements:
"All men are mortal": ∀x(M(x)→R(x)) This means "For all x, if x is a man, then x is mortal."
"Socrates is a man": M(S) This represents "Socrates is a man."
Conclusion - "Therefore, Socrates is mortal": R(S) This concludes that "Socrates is mortal."
Basic elements ATOMIC SENTENCE
•Atomic sentences are the most basic sentences of first-order
logic. These sentences are formed from a predicate symbol
Constant 1, 2, A, John, Mumbai, cat,.... followed by a parenthesis with a sequence of terms.
Variables x, y, z, a, b,....
•We can represent atomic sentences as Predicate (term1,
Predicates Brother, Father, >,.... term2, ......, term n)
Function sqrt, LeftLegOf, .... •Example-Ravi and Ajay are brothers: => Brothers(Ravi,
Ajay).
Connectives ∧, ∨, ¬, ⇒, ⇔ Chinky is a cat: => cat (Chinky).
Equality ==
COMPLEX SENTENCE
Quantifier ∀, ∃
•Complex sentences are made by combining atomic
sentences using connectives.
•Example –
∀x(Human(x)∧∃y(Parent(y,x)∧Doctor(y))→∃z(WorksAt(z,
x)∧Hospital(z)))
QUANTIFIERS
•A quantifier is a language element which
generates quantification, and quantification
1.Universal Quantifier, (for all, everyone,
specifies the quantity of specimen in the universe everything)
of discourse.
2.Existential quantifier, (for some, at least
•These are the symbols that permit to determine one).
or identify the range and scope of the variable in
the logical expression.
Universal Quantifier
Example:
All man drink coffee.
Let a variable x which refers to a cat so all x can be represented in
UOD as below:
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 as an existential quantifier.
1.Universal generalization is a valid inference rule that states that if premise P(c) is true for any arbitrary
element c in the universe of discourse, we can arrive at the conclusion as for all x P(x).
2.It can be represented as:
3.If we want to prove that every element has a similar property, we can apply this rule.
4.x must not be used as a free variable in this rule.
Example: Let's represent, P(c): "A byte contains 8 bits", so "All bytes contain 8 bits."for ∀ x P(x) , it
will also be true.
Universal Instantiation:
1.A valid inference rule is universal instantiation, often known as universal elimination or UI. It can be used to add additional
sentences many times.
2.The new knowledge base is logically equal to the existing knowledge base.
3.We can infer any phrase by replacing a ground word for the variable, according to UI
4.The UI rule say that we can infer any sentence P(c) by substituting a ground term c (a constant within domain x) from ∀ x
P(x) for any object in the universe of discourse.
5.It can be represented as
Example: 1
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge base.
1.An existential generalization is a valid inference rule in first-order logic that is also known as an existential introduction.
2.This rule argues that if some element c in the universe of discourse has the property P, we can infer that something in the universe has
the attribute P.
3.It's written like this: