Module 4.1
Module 4.1
REASONING
Module 4.1
BUILDING A KNOWLEDGE BASE
• Intelligence of humans is achieved—not by purely reflex mechanisms but by processes of reasoning that operate on
internal representations of knowledge.
2
• Inference mechanisms are hidden inside TELL and ASK.
• MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent perceived the given percept at the
given time.
• MAKE-ACTION-QUERY constructs a sentence that asks what action should be done at the current time.
• Finally, MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen action was
executed.
3
• A knowledge-based agent can be built simply by TELLing it what it needs to know
• Starting with an empty knowledge base, the agent designer can TELL sentences one by one until the agent knows
how to operate in its environment.
4
TYPES OF
KNOWLEDGE
5
TYPES
6
DECLARATIVE
• Declarative knowledge is to know about something.
• It includes concepts, facts, and objects.
• It is also called descriptive knowledge and expressed in declarative sentences.
• It is simpler than procedural language.
PROCEDURAL
• It is also known as imperative knowledge.
• Procedural knowledge is a type of knowledge which is responsible for knowing how to
do something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures, agendas, etc.
• Procedural knowledge depends on the task on which it can be applied.
7
META
• Knowledge about the other types of knowledge is called Meta-knowledge.
HEURISTIC
• Heuristic knowledge is representing knowledge of some experts in a filed or subject.
• Heuristic knowledge is rules of thumb based on previous experiences, awareness of
approaches, and which are good to work but not guaranteed.
STRUCTURAL
•Structural knowledge is basic knowledge to problem-solving.
•It describes relationships between various concepts such as kind of, part of, and
grouping of something.
•It describes the relationship that exists between concepts or objects.
8
PROPOSITIONAL
LOGIC
9
SYNTAX OF PROPOSITIONAL LOGIC
• The syntax of propositional logic defines the allowable sentences.
• The atomic sentences consist of a single proposition symbol.
• Each such symbol stands for a proposition that can be true or false.
• We use symbols that start with an uppercase letter and may contain other letters or
subscripts, for example: P, Q, R, W1,3 and North.
• There are two proposition symbols with fixed meanings: True is the always-true
proposition and False is the always-false proposition.
• Complex sentences are constructed from simpler sentences, using parentheses and
logical connectives.
• There are five connectives in common use:
1) ¬ (not)
A sentence such as ¬W1,3 is called the negation of W1,3. A literal is either an
atomic sentence (a positive literal) or a negated atomic sentence (a negative
literal).
10
2) ∧ (and)
A sentence whose main connective is ∧, such as W1,3 ∧ P3,1, is called a
conjunction; its parts are the conjuncts. (The ∧ looks like an “A” for “And.”)
3) v (or)
A sentence using ∨, such as (W1,3∧P3,1)∨W2,2, is a disjunction of the disjuncts
(W1,3 ∧ P3,1) and W2,2. (Historically, the ∨ comes from the Latin “vel,” which
means “or.” For most people, it is easier to remember ∨ as an upside-down ∧.)
4) ⇒ (implies)
A sentence such as (W1,3∧P3,1) ⇒ ¬W2,2 is called an implication (or
conditional). Its premise or antecedent is (W1,3 ∧P3,1), and its conclusion or
consequent is ¬W2,2. Implications are also known as rules or if–then statements.
The implication symbol is sometimes written in other books as ⊃ or →.
5) ⇔ (if and only if)
The sentence W1,3 ⇔ ¬W2,2 is a biconditional. Some other books write this as ≡.
11
12
13
WUMPUS
PROBLEM IN AI
14
15
FIRST ORDER
LOGIC
16
FIRST ORDER LOGIC
• A knowledge-based agent represents the world in which it operates and deduces what
actions to take.
• Propositional logic can be used as our representation language because it sufficed to
illustrate the basic concepts of logic and knowledge-based agents.
• However, propositional logic cannot be used to represent knowledge of complex
environments in a concise way.
• First-order logic is sufficiently expressive to represent a good deal of our
commonsense knowledge.
• Propositional logic is a declarative language because its semantics are based on a truth
relation between sentences and possible worlds.
• It also has sufficient expressive power to deal with partial information, using
disjunction and negation.
• Propositional logic has a third property that is desirable in representation languages,
namely, compositionality. 17
• In a compositional language, the meaning of a sentence is a function of the meaning of its parts.
• The language of first-order logic, is built around objects and relations.
• First-order logic can also express facts about some or all of the objects in the universe.
• The primary difference between propositional and first-order logic lies in the ontological
commitment made by each language—that is, what it assumes about the nature of reality.
• Mathematically, this commitment is expressed through the nature of the formal models with respect
to which the truth of sentences is defined.
• For example, propositional logic assumes that there are facts that either hold or do not hold in the
world.
• Each fact can be in one of two states: true or false, and each model assigns true or false to each
proposition symbol.
• First-order logic assumes more; namely, that the world consists of objects with certain relations
among them that do or do not hold.
• The formal models are correspondingly more complicated than those for propositional logic.
18
• A logic can also be characterized by its epistemological commitments- the possible
states of knowledge that it allows with respect to each fact.
• In both propositional and first order logic, a sentence represents a fact and the agent
either believes the sentence to be true, believes it to be false, or has no opinion.
• These logics therefore have three possible states of knowledge regarding any sentence.
19
• The basic syntactic elements of first-order logic are the symbols that stand for objects,
relations, and functions.
• The symbols, therefore, come in three kinds: constant symbols, which stand for
objects; predicate symbols, which stand for relations; and function symbols, which
stand for functions.
• As in propositional logic, every model must provide the information required to
determine if any given sentence is true or false.
• Thus, in addition to its objects, relations, and functions, each model includes an
interpretation that specifies exactly which objects, relations and functions are referred
to by the constant, predicate, and function symbols.
20
21
• In summary, a model in first-order logic consists of a set of objects and an interpretation that maps
constant symbols to objects, predicate symbols to relations on those objects, and function symbols to
functions on those objects.
• Just as with propositional logic, entailment, validity, and so on are defined in terms of all possible
models.
• These models vary in how many objects they contain—from one up to infinity—and in the
way the constant symbols map to objects.
• If there are two constant symbols and one object, then both symbols must refer to the same
object; but this can still happen even with more objects.
• When there are more objects than constant symbols, some of the objects will have no names.
22
• A term is a logical expression that refers to an object.
• Constant symbols are therefore terms, but it is not always convenient to have a distinct
symbol to name every object.
• An atomic sentence is formed from a predicate symbol optionally followed by a
parenthesized list of terms.
• An atomic sentence is true in a given model if the relation referred to by the predicate
symbol holds among the objects referred to by the arguments.
• We can use logical connectives to construct more complex sentences, with the same
syntax and semantics as in propositional calculus.
• Quantifiers let us express properties of entire collections of objects, instead of
enumerating the objects by name.
• First-order logic contains two standard quantifiers, called universal ( ∀) and existential (∃).
• Universal quantification makes statements about every object. Similarly, we can make a
statement about some object in the universe without naming it, by using an existential
quantifier.
23
KNOWLEDGE ENGINEERING IN FIRST-ORDER
•
LOGIC
The general process of knowledge-base construction is called knowledge engineering.
• A knowledge engineer is someone who investigates a particular domain, learns what
concepts are important in that domain, and creates a formal representation of the objects
and relations in the domain.
• Knowledge engineering projects vary widely in content, scope, and difficulty, but all such
projects include the following steps:
1. Identify the task:
The knowledge engineer must delineate the range of questions that the knowledge base
will support and the kinds of facts that will be available for each specific problem
instance.
2. Assemble the relevant knowledge:
The knowledge engineer might already be an expert in the domain or might need to
work with real experts to extract what they know—a process called knowledge
acquisition. At this stage, the knowledge is not represented formally. The idea is to
understand the scope of the knowledge base, as determined by the task, and to
understand how the domain works.
24
3. Decide on a vocabulary of predicates, functions, and constants:
Translates the important domain-level concepts into logic-level names. This involves
many questions of knowledge-engineering style. Like programming style, this can
have a significant impact on the eventual success of the project. Once the choices have
been made, the result is a vocabulary that is known as the ontology of the domain. The
word ontology means a particular theory of the nature of being or existence. The
ontology determines what kinds of things exist but does not determine their specific
properties and interrelationships.
4. Encode general knowledge about the domain:
The knowledge engineer writes down the axioms for all the vocabulary terms. This
pins down the meaning of the terms, enabling the expert to check the content. Often,
this step reveals misconceptions or gaps in the vocabulary that must be fixed by
returning to step 3 and iterating through the process.
5. Encode a description of the specific problem instance:
If the ontology is well thought out, this step will be easy. It will involve writing simple
atomic sentences about instances of concepts that are already part of the ontology. For
a logical agent, problem instances are supplied by the sensors, whereas a
“disembodied” knowledge base is supplied with additional sentences in the same way
that traditional programs are supplied with input data.
25
6. Pose queries to the inference procedure and get answers:
This is where the reward is: we can let the inference procedure operate on the axioms
and problem-specific facts to derive the facts we are interested in knowing. Thus, we
avoid the need for writing an application-specific solution algorithm.
7. Debug the knowledge base:
Alas, the answers to queries will seldom be correct on the first try. More precisely, the
answers will be correct for the knowledge base as written, assuming that the inference
procedure is sound, but they will not be the ones that the user is expecting. For
example, if an axiom is missing, some queries will not be answerable from the
knowledge base. A considerable debugging process could ensue. Missing axioms or
axioms that are too weak can be easily identified by noticing places where the chain of
reasoning stops unexpectedly.
26
SITUATION
CALCULUS
27
SITUATION CALCULUS
• The idea behind situation calculus is that (reachable) states are definable in terms of
the actions required to reach them.
• These reachable states are called situations.
• What is true in a situation can be defined in terms of relations with the situation as an
argument.
• Situation calculus can be seen as a relational version of the feature-based
representation of actions.
• Here we only consider single agents, a fully observable environment, and
deterministic actions.
• Situation calculus is defined in terms of situations.
• A situation is either
⮚ init, the initial situation, or
⮚ do(A,S), the situation resulting from doing action A in situation S, if it is possible
to do action A in situation S.
28
• Situation calculus is used for planning by asking for a situation in which a goal is
true.
• Answer extraction is used to find a situation in which the goal is true.
• This situation can be interpreted as a sequence of actions for the agent to perform.
• Using the top-down proof procedure on the situation calculus definitions is very
inefficient, because a frame axiom is almost always applicable.
• A complete proof procedure, such as iterative deepening, searches through all
permutations of actions even if they are not relevant to the goal.
• A situation can be associated with a state. There are two main differences between
situations and states:
⮚ Multiple situations may refer to the same state if multiple sequences of actions
lead to the same state. That is, equality between situations is not the same as
equality between states.
⮚ Not all states have corresponding situations. A state is reachable if a sequence of
actions exists that can reach that state from the initial state. States that are not
reachable do not have a corresponding situation.
29
THEOREM
PROVING IN FIRST
ORDER LOGIC
First-order logic (FOL) refers to logic in which
the predicate of a sentence or statement can
only refer to a single subject.
30
THEOREM PROVING IN FOL
• Resolution is a theorem proving technique that proceeds by building refutation proofs,
i.e., proofs by contradictions.
• 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.
• Disjunction of literals (an atomic sentence) is called a clause. It is also known as a unit
clause.
• A sentence represented as a conjunction of clauses is said to be conjunctive normal
form.
• 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. 31
STEPS FOR RESOLUTION
1. Conversion of facts into first-order logic.
2. Convert FOL statements into CNF
3. Negate the statement which needs to prove (proof by contradiction)
4. Draw resolution graph (unification).
32
PLANNING
33
PLANNING
• The planning in Artificial Intelligence is about the decision-making tasks
performed by the robots or computer programs to achieve a specific goal.
• The execution of planning is about choosing a sequence of actions with a high
likelihood to complete the specific task.
38
UNCERTAIN
KNOWLEDGE
AND REASONING
39
UNCERTAIN KNOWLEDGE
In real life, it is not always possible to determine the state of the environment as it
might not be clear. Due to partially observable or non-deterministic environments,
agents may need to handle uncertainty and deal with:
• Uncertain data: Data that is missing, unreliable, inconsistent or noisy
• Uncertain knowledge: When the available knowledge has multiple causes
leading to multiple effects or incomplete knowledge of causality in the domain
• Uncertain knowledge representation: The representations which provides a
restricted model of the real system, or has limited expressiveness
• Inference: In case of incomplete or default reasoning methods, conclusions
drawn might not be completely accurate.
40
• With knowledge representation, we might write A→B, which means if A is true then B
is true but consider a situation where we are not sure about whether A is true or not then
we cannot express this statement, this situation is called uncertainty.
• So, to represent uncertain knowledge, where we are not sure about the predicates, we
need uncertain reasoning or probabilistic reasoning.
42
Need of probabilistic reasoning in AI:
• When there are unpredictable outcomes.
• When specifications or possibilities of predicates becomes too large to handle.
• When an unknown error occurs during an experiment.
In probabilistic reasoning, there are two ways to solve problems with uncertain
knowledge:
• Bayes' rule
• Bayesian Statistics
43
PROBABILITIES
44
PROBABILITY
• Probability can be defined as a chance that an uncertain event will occur.
• It is the numerical measure of the likelihood that an event will occur.
• It provides a certain degree of belief in case of uncertain situations.
• The value of probability always remains between 0 and 1 that represent ideal
uncertainties.
⮚ 0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.
⮚ P(A) = 0, indicates total uncertainty in an event A.
⮚ P(A) =1, indicates total certainty in an event A.
• The probability of an uncertain event can be found using:
45
• Event: Each possible outcome of a variable is called an event.
• Sample space: The collection of all possible events is called sample space.
• Random variables: Random variables are used to represent the events and objects
in the real world.
• Prior probability: The prior probability of an event is probability computed before
observing new information.
• Posterior Probability: The probability that is calculated after all evidence or
information has been taken into account. It is a combination of prior probability and
new information.
46
CONDITIONAL PROBABILITY
• Conditional probability or Posterior Probability is a probability of occurring an event when
another event has already happened.
• We can calculate the event A when event B has already occurred, "the probability of A under
the conditions of B", it can be written as:
• If the probability of A is given and we need to find the probability of B, then it will be given
as:
47
THANK YOU