0% found this document useful (0 votes)
25 views32 pages

Week 7

Android application note

Uploaded by

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

Week 7

Android application note

Uploaded by

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

Topic:BCA–508 Unit -3 Artificial

Intelligence (Week 7)

Prepared By:
Dr Tejinder Kaur
Associate Professor
Programme: BCA -50
8

Cours
e: Artificial Intelligen
ce

Contents
• Logic Programming and Knowledge Representation
• The predicate calculus
• Syntax and semantic for propositional logic and
FOPL
• Clausal form
• inference rules
• resolution and unification
Programme: BCA -50
8

Cours
e: Artificial Intelligen

Logic Programming and Knowledge


ce

Representation
• There are mainly four ways of knowledge representation which are given
as follows:
• Logical Representation
• Semantic Network Representation
• Frame Representation
• Production Rules
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• 1. Logical Representation
• Logical representation is a language with some concrete rules which deals
with propositions and has no ambiguity in representation. Logical
representation means drawing a conclusion based on various conditions.
This representation lays down some important communication rules. It
consists of precisely defined syntax and semantics which supports the
sound inference. Each sentence can be translated into logics using syntax
and semantics.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Syntax:
• Syntaxes are the rules which decide how we can construct legal sentences
in the logic.
• It determines which symbol we can use in knowledge representation.
• How to write those symbols.
• Semantics:
• Semantics are the rules by which we can interpret the sentence in the logic.
• Semantic also involves assigning a meaning to each sentence.
• Logical representation can be categorised into mainly two logics:
• Propositional Logics
• Predicate logics
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Advantages of logical representation:
• Logical representation enables us to do logical reasoning.
• Logical representation is the basis for the programming languages.
• Disadvantages of logical Representation:
• Logical representations have some restrictions and are challenging to work
with.
• Logical representation technique may not be very natural, and inference
may not be so efficient
knowledge in the form of graphical networks. This network consists of nodes representing objects and arcs which describe the relationship between those objects. Semantic networks can categorize the ob

Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• 2. Semantic Network Representation
• Semantic networks are alternative of predicate logic for knowledge representation. In Semantic
networks, we can represent our knowledge in the form of graphical networks. This network
consists of nodes representing objects and arcs which describe the relationship between those
objects. Semantic networks can categorize the object in different forms and can also link those
objects. Semantic networks are easy to understand and can be easily extended. This representation
consist of mainly two types of relations:
• IS-A relation (Inheritance)
• Kind-of-relation
• Example: Following are some statements which we need to represent in the form of nodes and
arcs.
• Statements:
• Jerry is a cat.
• Jerry is a mammal
• Jerry is owned by Priya.
• Jerry is brown colored.
• All Mammals are animal.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• In the above diagram, we have represented the different type of knowledge in
the form of nodes and arcs. Each object is connected with another object by
some relation.
Drawbacks in Semantic representation:
• Semantic networks take more computational time at runtime as we need to
traverse the complete network tree to answer some questions. It might be
possible in the worst case scenario that after traversing the entire tree, we find
that the solution does not exist in this network.
• Semantic networks try to model human-like memory (Which has 1015
neurons and links) to store the information, but in practice, it is not possible to
build such a vast semantic network.
• These types of representations are inadequate as they do not have any
equivalent quantifier, e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link names.
• These networks are not intelligent and depend on the creator of the system.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
Advantages of Semantic network:
Semantic networks are a natural representation of knowledge.
Semantic networks convey meaning in a transparent manner.
These networks are simple and easily understandable.
3. Frame Representation
A frame is a record like structure which consists of a collection of attributes and its
values to describe an entity in the world. Frames are the AI data structure which divides
knowledge into substructures by representing stereotypes situations. It consists of a
collection of slots and slot values. These slots may be of any type and sizes. Slots have
names and values which are called facets.
Facets: The various aspects of a slot is known as Facets. Facets are features of frames
which enable us to put constraints on the frames. Example: IF-NEEDED facts are called
when data of any particular slot is needed. A frame may consist of any number of slots,
and a slot may include any number of facets and facets may have any number of values.
A frame is also known as slot-filter knowledge representation in artificial intelligence.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Advantages of frame representation:
• The frame knowledge representation makes the programming easier by
grouping the related data.
• The frame representation is comparably flexible and used by many
applications in AI.
• It is very easy to add slots for new attribute and relations.
• It is easy to include default data and to search for missing values.
• Frame representation is easy to understand and visualize.
• Disadvantages of frame representation:
• In frame system inference mechanism is not be easily processed.
• Inference mechanism cannot be smoothly proceeded by frame
representation.
• Frame representation has a much generalized approach.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
4. Production Rules
• Production rules system consist of (condition, action) pairs which mean, "If condition then
action". It has mainly three parts:
• The set of production rules
• Working Memory
• The recognize-act-cycle
• In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of the rule
determines which rule may be applied to a problem. And the action part carries out the
associated problem-solving steps. This complete process is called a recognize-act cycle.
• The working memory contains the description of the current state of problems-solving and
rule can write knowledge to the working memory. This knowledge match and may fire
other rules.
• If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from
these sets, and it is called a conflict resolution.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
Advantages of Production rule:
• The production rules are expressed in natural language.
• The production rules are highly modular, so we can easily remove, add or
modify an individual rule.
• Disadvantages of Production rule:
• Production rule system does not exhibit any learning capabilities, as it does
not store the result of the problem for the future uses.
• During the execution of the program, many rules may be active hence rule-
based production systems are inefficient.
Programme: BCA -
508

Course: Artificial
Intelligence

The predicate calculus,


Predicate calculus provides a notation and inference rules for constructing
and reasoning about propositions (statements) composed of predicate
applications, operators (and, or, not, etc.), and the quantifiers ∀ and ∃.
Logic programming formalizes the search for variable values that will
make a given proposition true.
AI systems can use predicates to perform tasks like deductive reasoning,
semantic query answering, and decision making. For example, an AI
system can infer that if "x is a parent of y" and "x is a human," then "y is
also a human."
Programme: BCA -
508

Syntax and semantic for propositional


Course: Artificial
Intelligence

logic and FOPL


First-order logic (FOL), also known as first-order predicate logic, is a
fundamental formal system used in mathematics, philosophy, computer
science, and linguistics for expressing and reasoning about relationships
between objects in a domain. In artificial intelligence (AI), first-order logic
(FOL) serves as a cornerstone for representing and reasoning about
knowledge. Its syntax and semantics provide a robust framework for
encoding information in a precise and structured manner, enabling AI
systems to perform tasks such as automated reasoning, planning, and
natural language understanding.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue

• Syntax of First-Order Logic


• The syntax of first-order logic consists of symbols and rules for
constructing well-formed formulas (WFFs), which are statements or
formulas in the language of FOL. The syntax encompasses the language
constructs used to express knowledge and relationships within a domain.
• Terms in First-Order Logic
• Terms represent objects or entities within the domain of discourse. In AI,
terms can correspond to real-world entities, such as objects, individuals, or
abstract concepts. They include:
• Constants: Specific entities, e.g., “John”, “Apple”.
• Variables: Placeholders for entities, e.g., “x”, “y”.
• Functions: Expressions applied to terms, e.g., “Age(John)”, “Parent(x)”.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Predicates in First-Order Logic
• Predicates express properties, relations, or conditions that hold between
objects. They describe the state of the world or assert facts about entities
within the domain. Examples include:
• “IsHuman(x)”
• “IsParent(x, y)”
• Quantifiers in First-Order Logic
• Quantifiers in first-order logic allow for the specification of statements
about the entirety or existence of objects within the domain.
• Universal quantifiers (∀): Statements that hold for all objects.
• Existential quantifiers (∃): Statements that hold for at least one object.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Connectives in First-Order Logic
• Logical connectives such as conjunction (∧), disjunction (∨),
implication (→), and negation (¬) enable the composition of complex
statements from simpler ones. They facilitate the expression of
logical relationships and constraints in AI knowledge representations.
• Connectives in First-Order Logic
• Conjunction (∧):
▫ Meaning: Represents logical “and” between two propositions. The
conjunction of two propositions is true only if both propositions
are true.
▫ Example: If P(x) represents “x is red” and Q(x) represents “x is
round”, then P(x)∧Q(x) represents “x is red and round”.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Disjunction (∨):
▫ Meaning: Represents logical “or” between two propositions. The
disjunction of two propositions is true if at least one of the
propositions is true.
▫ Example: If P(x) represents “x is a cat” and Q(x) represents “x is a
dog”, then P(x)∨Q(x) represents “x is either a cat or a dog”.
• Implication (→):
▫ Meaning: Represents logical “if-then” relationship between two
propositions. The implication P→Q is true if either Q is true or if P
is false.
▫ Example: If P(x) represents “x is a mammal” and Q(x) represents
“x produces milk”, then P(x)→Q(x) represents “if x is a mammal,
then it produces milk”.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
Semantics of First-Order Logic
• Semantics in first-order logic deals with the interpretation of sentences and
formulas within the framework of a mathematical model. It provides a way to
assign meanings to the symbols and structures used in first-order logic.
• Key Elements of Semantics in First-Order Logic
• Variables: These represent placeholders for objects or elements within a
domain.
• Constants: These represent specific elements within the domain.
• Predicates: These are expressions that can be true or false depending on the
objects they’re applied to.
• Functions: These map elements from the domain to other elements in the
domain.
• Quantifiers: Such as “for all” (∀) and “exists” (∃), used to express universal
and existential quantification, respectively.
Programme: BCA -
508

Course: Artificial
Intelligence

Clausal form
A formula in clausal form consists of a conjunction of clauses. Each clause is a
disjunction of literals. Each literal is either an atomic sentence or the negation of an
atomic sentence, where an atomic sentence is a predicate applied to some terms.
• In clausal form, the formula is made up of a number of clauses, where each clause is
composed of a number of literals connected by OR logical connectives only.
• A formula can have the following quantifiers:
• Universal quantifier –
It can be understood as – “For all x, P(x) holds”, meaning P(x) is true for every object
x in the universe.
Example: All trucks has wheels.

• Existential quantifier –
It can be understood as – “There exists an x such that P(x)”, meaning P(x) is true for
at least one object x of the universe.
Example: Someone cares for you.
Programme: BCA -50
8

Cours
e: Artificial Intelligen
ce

Continue
A clausal form formula must be transformed into another formula with the
following characteristics :
All variables in the formula are universally quantified. Hence, it is not
necessary to include the universal quantifiers explicitly for all. The
quantifiers are removed, and all variables in the formula are implicitly
quantified by the universal quantifier.
• As the formula is made up of a number of clauses, and each clause is
composed of a number of literals connected by OR logical connectives
only. Hence, each clause is a disjunction of literals.

• To form a formula, the clauses themselves are connected by AND logical


connectives only. Hence, clausal form of a formula is a conjunction of
clauses.
Programme: BCA -
508

Course: Artificial
Intelligence

inference rules
• Inference rules are the templates for generating valid arguments. Inference
rules are applied to derive proofs in artificial intelligence, and the proof is a
sequence of the conclusion that leads to the desired goal.
• In inference rules, the implication among all the connectives plays an
important role. Following are some terminologies related to inference rules:
• Implication: It is one of the logical connectives which can be represented as P
→ Q. It is a Boolean expression.
• Converse: The converse of implication, which means the right-hand side
proposition goes to the left-hand side and vice-versa. It can be written as Q →
P.
• Contrapositive: The negation of converse is termed as contrapositive, and it
can be represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be represented as
¬ P → ¬ Q.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• Types of Inference rules:
1. Modus Ponens: The Modus Ponens rule is one of the most important rules of
inference, and it states that if P and P → Q is true, then we can infer that Q will be
true.
• Example:
• Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.
• 2. Modus Tollens:
• The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also true.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• 3. Hypothetical Syllogism:
• The Hypothetical Syllogism rule state that if P→R is true whenever
P→Q is true, and Q→R is true. It can be represented as the
following notation:
• Example:
• Statement-1: If you have my home key then you can unlock my
home. P→Q
Statement-2: If you can unlock my home then you can take my
money. Q→R
Conclusion: If you have my home key then you can take my
money. P→R
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• 4. Disjunctive Syllogism:
• The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true,
then Q will be true.

• Example:
• Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• 5. Addition:
• The Addition rule is one the common inference rule, and it states that If P
is true, then P∨Q will be true.
• 6. Simplification:
• The simplification rule state that if P∧ Q is true, then Q or P will also be
true.
• 7. Resolution:
• The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q ∨R will
also be true.
Programme: BCA -
508

Course: Artificial
Intelligence

resolution and unification


• Resolution is a theorem proving technique that proceeds by building
refutation proofs, i.e., proofs by contradictions. It was invented by a
Mathematician John Alan Robinson in the year 1965.
• Resolution is used, if there are various statements are given, and we
need to prove a conclusion of those statements. Unification is a key
concept in proofs by resolutions. Resolution is a single inference rule
which can efficiently operate on the conjunctive normal form or
clausal form.
• Clause: Disjunction of literals (an atomic sentence) is called a clause.
It is also known as a unit clause.
• Conjunctive Normal Form: A sentence represented as a conjunction
of clauses is said to be conjunctive normal form or CNF.
Programme: BCA -
508

Course: Artificial
Intelligence

Continue
• The resolution inference rule:
• The resolution rule for first-order logic is simply a lifted version of the
propositional rule. Resolution can resolve two clauses if they contain
complementary literals, which are assumed to be standardized apart so that
they share no variables.
• Steps for Resolution:
• Conversion of facts into first-order logic.
• Convert FOL statements into CNF
• Negate the statement which needs to prove (proof by contradiction)
• Draw resolution graph (unification).
• To better understand all the above steps, we will take an example in which
we will apply resolution.
Programme: BCA

Course: Co
mputer Network

Unification

• Unification is a process of making two different logical atomic expressions


identical by finding a substitution. Unification depends on the substitution
process.
• It takes two literals as input and makes them identical using substitution.
• Conditions for Unification:
• Following are some basic conditions for unification:
• Predicate symbol must be same, atoms or expression with different
predicate symbol can never be unified.
• Number of Arguments in both expressions must be identical.
• Unification will fail if there are two similar variables present in the same
expression.
Programme: BCA

Course: Co
mputer Network

Continue
• Implementation of the Algorithm
• Step.1: Initialize the substitution set to be empty.
• Step.2: Recursively unify atomic sentences:
• Check for Identical expression match.
• If one expression is a variable vi, and the other is a term ti which
does not contain variable vi, then:
▫ Substitute ti / vi in the existing substitutions
▫ Add ti /vi to the substitution setlist.
▫ If both the expressions are functions, then function name must be
similar, and the number of arguments must be the same in both
the expression.
Programme: BCA -50
8

Cours
e: Artificial Intelligen
ce

Query
?????

You might also like