BTech Advanced AI Unit01 (C)
BTech Advanced AI Unit01 (C)
Dr.Vaishnaw G.Kale
Associate Professor
Department of Computer Science
Engineering & Applications
D.Y.Patil International University, Pune
About the Course
Propositional Logic: Propositional Theorem Proving, Agents Based on Propositional Logic, First-
Order Logic, Syntax and Semantics of First-Order Logic, Using First-Order Logic, Knowledge
Engineering in First-Order Logic, knowledge representation using propositional and predicate
logic, comparison of propositional and predicate logic, reasoning,types of Reasoning
Advanced Artificial Intelligence
● Propositional logic
● First-order logic
when thinking about logical agents, we imagine that the agent has a knowledge base (KB) that
contains logical sentences that describe the state of the world you could think of a KB as a database
designed for storing and retrieving logical sentences there are two main KB operations: TELL and
ASK
● ASK queries the KB about what is known; this usually involves inference, where the KB can
determine that facts are true (or likely to be true) even though they have not been explicitly told
them
Logical Agent
1) Propositional Logic(PL)
● Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions.
● A proposition is a declarative statement which is either true or false.
● It is a technique of knowledge representation in logical and mathematical form.
Examples
a) It is Sunday.
d) 5 is a prime number.
Logical Agent
1) Propositional Logic(PL)
● Propositional logic is also called Boolean logic as it works on 0 and 1.
● In propositional logic, we use symbolic variables to represent the logic, and we can use any
symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
● Propositions can be either true or false, but it cannot be both.
● Propositional logic consists of an object, relations or function, and logical connectives.
● These connectives are also called logical operators.
● The propositions and connectives are the basic elements of the propositional logic.
● Connectives can be said as a logical operator which connects two sentences.
● A proposition formula which is always true is called tautology, and it is also called a valid
sentence.
● A proposition formula which is always false is called Contradiction.
● Statements which are questions, commands, or opinions are not propositions such as "Where is
Rohini", "How are you", "What is your name", are not propositions.
Logical Agent
Syntax of Propositional Logic(PL)
● The syntax of propositional logic defines the allowable sentences for the knowledge representation.
There are two types of Propositions:
a. Atomic Propositions: They are the simple propositions. It consists of a single proposition symbol. These
are the sentences which must be either true or false.
Example
2+2 is 4, it is an atomic proposition as it is a true fact.
"The Sun is cold" is also a proposition as it is a false fact
b. Compound propositions: They are constructed by combining simpler or atomic propositions, using
parentheses and logical connectives.
● Example
"It is raining today, and street is wet."
"Ankit is a doctor, and his clinic is in Mumbai."
Logical Agent
Logical Connectives in Propositional Logic(PL)
● Logical connectives are used to connect two simpler propositions or representing a sentence logically.
We can create compound propositions with the help of logical connectives.
● There are mainly five connectives, which are given as follows:
1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or
negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and Q
are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Engineer, so we can write it as P ∨ Q.
Logical Agent
Logical Connectives in Propositional Logic(PL)
4) Implication: A sentence such as P → Q, is called an implication. Implications are also known as if-then
rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5) Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I am breathing, then I am
alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Limitations
● We cannot represent relations like ALL, some, or none with propositional logic. Example:
a. All the girls are intelligent.
b. Some apples are sweet.
● Propositional logic has limited expressive power.
● In propositional logic, we cannot describe statements in terms of their properties or logical
relationships
Logical Agent
First Order Logic(FOL)
● Unfortunately, in propositional logic (PL), we can only represent the facts, which are either true or
false.
● PL is not sufficient to represent the complex sentences or natural language statements.
● The propositional logic has very limited expressive power.
To represent the above statements, PL logic is not sufficient, so we required some more powerful logic, such
as first-order logic.
Logical Agent
First Order Logic(FOL)/Predicate Logic/First Order Predicate Logic
As a natural language, first-order logic also has two main parts: Syntax and Semantics
Syntax of FOL
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.
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, term 2... term n).
Example: Ravi and Ajay are brothers: => Brothers (Ravi, Ajay)
Complex Sentences
● Complex sentences are made by combining atomic sentences using connectives.
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.
Logical Agent
Semantic(relating to meaning in language or logic) of FOL
The value of function expression is that element of D obtained by evaluating the function for
parameter values assigned by I.
The value of negation of sentence is True if value of sentence is false and vice and versa.
The value of conjunction of two sentence is true if both are true otherwise false.
The true value of expression using are determined form the value of other operands
Knowledge based Agent
● An intelligent agent needs knowledge about the real world for taking decisions and reasoning to
act efficiently.
● Knowledge-based agents are those agents who have the capability of maintaining an internal
state of knowledge, reason over that knowledge, update their knowledge after observations and
take actions.
● These agents can represent the world with some formal representation and act intelligently.
Knowledge-based agents are composed of two main parts:
o Knowledge-base: domain specific content and
o Inference system: Domain Independent system
Knowledge based Agent
Following are three operations which are performed by KBA in order to show the intelligent behavior:
1. TELL: This operation tells the knowledge base what it perceives from the environment.
2. ASK: This operation asks the knowledge base what action it should perform.
3. Perform: It performs the selected action.
Knowledge based Agent
● The knowledge-based agent takes percept as input and returns an action as output.
● The agent maintains the knowledge base, KB, and it initially has some background knowledge
of the real world.
● It also has a counter to indicate the time for the whole process, and this counter is initialized
with zero.
Each time when the function is called, it performs its three operations:
● Firstly it TELLs the KB what it perceives.
● Secondly, it asks KB what action it should take
● Third agent program TELLS the KB that which action was chosen.
Knowledge based Agent
Approaches
1. Declarative approach:
● We can create a knowledge-based agent by initializing with an empty knowledge base and telling
the agent all the sentences with which we want to start with.
● This approach is called Declarative approach.
2. Procedural approach:
● We can show how entailment can be done by theorem proving that is applying rules of inference
directly to the sentences in our knowledge base to construct as proof of the desired sentence without
consulting models.
● Logical equivalence: Two sentences Alpha and Beta are logically equivalent if they are true in the
same set of models.
we write this Alpha =Beta. For example we can easily show (using truth table) that P^Q and Q^P are
logically equivalent.
● Consider when the agent moves forward , this fact goes into KB.
● When we forgot to include what has remain unchanged, the need of this leads to frame problem.
● To resolve this problem we can add from axioms but this is really inefficient. This specific problem often is called
as representational frame problem.
● To resolve this problem we can write axioms about fluent not actions.
● With successor state axioms and previously defined axioms the agent can ASK anything that can be answered in
the world.
● Use of hybrid agent which combine condition action rules. This agent keeps an update plan and KB. KB is
initialized with atemporal axioms.
● In this as time passes new percept axioms are added and all axioms related to time( Successor time axioms).
● Questions are called queries or goals. queries are logically entailed by KB should be answered
affirmatively should return true too
Using First Order Logic
● can ask quantified queries
Example facts : E is a mother of C, C is the father of W, Ones grandmother is mother of one's parent
The first step of the process is to identify the task, and for the digital circuit,
there are various reasoning tasks.
At the first level or highest level, we will examine the functionality of the
circuit:
● What will be the output of gate A2, if all the inputs are high?
In the second step, we will assemble the relevant knowledge which is required for digital circuits. So for digital
circuits, we have the following required knowledge:
● Signal flows through wires to the input terminal of the gate, and each gate produces the corresponding
output which flows further.
● In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.
● All these gates have one output terminal and two input terminals (except NOT gate, it has one input
terminal).
Knowledge Engineering in FOL
3.Decide on Vocabulary
● The next step of the process is to select functions, predicate, and constants to represent the circuits,
terminals, signals, and gates.
● Firstly we will distinguish the gates from each other and from other objects.
● Each gate is represented as an object which is named by a constant, such as, Gate(X1).
● The functionality of each gate is determined by its type, which is taken as constants such as AND, OR,
XOR, or NOT.
● Circuits will be identified by a predicate: Circuit (C1).
● For the terminal, we will use predicate: Terminal(x).
● For gate input, we will use the function In(1, X1) for denoting the first input terminal of the gate, and
for output terminal we will use Out (1, X1).
● The function Arity(c, i, j) is used to denote that circuit c has i input, j output.
● The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1)).
● We use a unary predicate On (t), which is true if the signal at a terminal is on.
Knowledge Engineering in FOL
4. Encode general knowledge of the domain
● Now we encode problem of circuit C1, firstly we categorize the circuit and its gate components.
● This step is easy if ontology about the problem is already thought.
● This step involves the writing simple atomics sentences of instances of concepts, which is known as
ontology.
● For the given circuit C1, we can encode the problem instance in atomic sentences as below:
● Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates
will be:
1. For XOR gate: Type(x1)= XOR, Type(X2) = XOR
2. For AND gate: Type(A1) = AND, Type(A2)= AND
3. For OR gate: Type (O1) = OR.
● In this step, we will find all the possible set of values of all the terminal for the adder circuit.
● The first query will be: What should be the combination of input which would generate the first
output of circuit C1, as 0 and a second output to be 1?
● Now we will debug the knowledge base, and this is the last step of the complete process.
● In this step, we will try to debug the issues of knowledge base.
● In the knowledge base, we may have omitted assertions like 1 ≠ 0.
Difference between Propositional & Predicate Logic
1. Propositional Logic :
A proposition is basically a declarative sentence that has a truth value.
● Truth value can either be true or false, but it needs to be assigned any of the two values and not be
ambiguous.
● The purpose of using propositional logic is to analyze a statement, individually or compositely.
For example :
The following statements :
1. If x is real, then x2 > 0
2. What is your name?
3. (a+b)2 = 100
4. This statement is true.
Are not propositions because they do not have a truth value. They are ambiguous.
Difference between Propositional & Predicate Logic
2. Predicate Logic :
● Predicates are properties, additional information to better express the subject of the sentence.
● A quantified predicate is a proposition , that is, when you assign values to a predicate with
variables it can be made a proposition.
For example :
In P(x) : x>5, x is the subject or the variable and ‘>5’ is the predicate.
P(7) : 7>5 is a proposition where we are assigning values to the variable x, and it has a truth value,
i.e. True.
Difference between Propositional & Predicate Logic
It is the basic and most widely used logic. Also It is an extension of propositional logic covering
known as Boolean logic. predicates and quantification.
A proposition has a specific truth value, either true A predicate truth value depends on the variables’
or false. value.
● The reasoning is the mental process of deriving logical conclusion and making predictions from
available knowledge, facts, and beliefs. Or we can say, "Reasoning is a way to infer facts from
existing data."
● It is a general process of thinking rationally, to find valid conclusions.
● In artificial intelligence, the reasoning is essential so that the machine can also think rationally as a
human brain, and can perform like a human.
Types of Reasoning
1) Deductive Reasoning
● Deductive reasoning is deducing new information from logically related known information.
It is the form of valid reasoning, which means the argument's conclusion must be true when
the premises are true.
● Deductive reasoning is a type of propositional logic in AI, and it requires various rules and
facts.
● It is sometimes referred to as top-down reasoning, and contradictory to inductive reasoning.
● In deductive reasoning, the truth of the premises guarantees the truth of the conclusion.
● Deductive reasoning mostly starts from the general premises to the specific conclusion
Reasoning
Example:
● Inductive reasoning is a form of reasoning to arrive at a conclusion using limited sets of facts
by the process of generalization. It starts with the series of specific facts or data and reaches
to a general statement or conclusion.
● Inductive reasoning is a type of propositional logic, which is also known as cause-effect
reasoning or bottom-up reasoning.
● In inductive reasoning, we use historical data or various premises to generate a generic rule,
for which premises support the conclusion.
● In inductive reasoning, premises provide probable supports to the conclusion, so the truth of
premises does not guarantee the truth of the conclusion.
Reasoning
2) Inductive Reasoning
● Inductive reasoning is a form of reasoning to arrive at a conclusion using limited sets of facts
by the process of generalization. It starts with the series of specific facts or data and reaches
to a general statement or conclusion.
● Inductive reasoning is a type of propositional logic, which is also known as cause-effect
reasoning or bottom-up reasoning.
● In inductive reasoning, we use historical data or various premises to generate a generic rule,
for which premises support the conclusion.
● In inductive reasoning, premises provide probable supports to the conclusion, so the truth of
premises does not guarantee the truth of the conclusion.
Reasoning
Example:
Premise: All of the pigeons we have seen in the zoo are white.
3) Abductive Reasoning
Abductive reasoning is a form of logical reasoning which starts with single or multiple
observations then seeks to find the most likely explanation or conclusion for the observation.
Example:
Conclusion It is raining.
Reasoning
4) Common Sense Reasoning
● Common sense reasoning is an informal form of reasoning, which can be gained through
experiences.
● Common Sense reasoning simulates the human ability to make presumptions about events
which occurs on every day.
● It relies on good judgment rather than exact logic and operates on heuristic knowledge and
heuristic rules.
Example:
● In monotonic reasoning, once the conclusion is taken, then it will remain the same even if we add
some other information to existing information in our knowledge base. In monotonic reasoning,
adding knowledge does not decrease the set of prepositions that can be derived.
● To solve monotonic problems, we can derive the valid conclusion from the available facts only, and
it will not be affected by new facts.
● Monotonic reasoning is not useful for the real-time systems, as in real time, facts get changed, so we
cannot use monotonic reasoning.
● Monotonic reasoning is used in conventional reasoning systems, and a logic-based system is
monotonic.
● Any theorem proving is an example of monotonic reasoning.
Reasoning
Example:
○ Earth revolves around the Sun.
It is a true fact, and it cannot be changed even if we add another sentence in knowledge base like, "The
moon revolves around the earth" Or "Earth is not round," etc.
Advantages of Monotonic Reasoning:
○ In monotonic reasoning, each old proof will always remain valid.
○ If we deduce some facts from available facts, then it will remain valid for always.
Disadvantages of Monotonic Reasoning:
○ We cannot represent the real world scenarios using Monotonic reasoning.
○ Hypothesis knowledge cannot be expressed with monotonic reasoning, which means facts should be
true.
○ so new knowledge from the real world cannot be added.
Reasoning
6) Non-monotonic Reasoning
Example: Let suppose the knowledge base contains the following knowledge:
○ Birds can fly
○ Penguins cannot fly
○ Pitty is a bird
So from the above sentences, we can conclude that Pitty can fly.
However, if we add one another sentence into knowledge base "Pitty is a penguin", which concludes
"Pitty cannot fly", so it invalidates the above conclusion.
Reasoning
○ For real-world systems such as Robot navigation, we can use non-monotonic reasoning.
○ In Non-monotonic reasoning, we can choose probabilistic facts or can make assumptions.
○ In non-monotonic reasoning, the old facts may be invalidated by adding new sentences.
○ It cannot be used for theorem proving.
Reasoning
○ Consider the following two examples to better understand how reasoning works in artificial
intelligence applications and systems:
1. Alexa: is a cognitive virtual assistant that employs reasoning to make recommendations and
suggestions based on orders. For instance, the closest place, the date for tomorrow, the AM and
PM, and so on.
○ In brief, machines, like humans, use reasoning, knowledge representation, logic, and learning
to analyze, solve problems, draw conclusions, and more.
Thank you!