Professional Documents
Culture Documents
AI ML Notes 2
AI ML Notes 2
AI ML Notes 2
The input signals arrive at the processing elements through connection and
connecting weights. Information stored in the neurons is basically the weighted
linkage of neurons.
It has the ability to learn, recall, and generalize from the data provided by proper
assignment and weight adjustment.
The collective behavior of the neurons its computational power, and no signal
neurons carry specific information.
It provides adaptive response to change in the surrounding environment.
Neural networks can be useful for pattern recognition or data classifications,
through a learning process.
Neural Networks
The neuron is the basic information processing unit of a NN. It consists of-
A set of links, describing the neuron inputs, with weights W1 , W2 , · · · Wm
An adder function (linear combiner) for computing the weighted sum of the
inputs (real numbers):
m
X
u= Wj Xj
j=1
Activation function Φ for limiting the amplitude of the neuron output. Here ’b’
denotes bias.
y = Φ(u + b)
The bias b has the effect of applying a transformation to the weighted sum u,
v=u+b
The bias is an external parameter of the neuron. It can be modeled by adding an
extra input.
v is called induced field of the neuron
m
X
v= Wj Xj , corresponding to j = 0, W0 = b
j=0
,
ANN: Terminologies
Weights indicated, weighted inputs connected to the neurons. if
there are ’n’ nodes with each node having ’m’ weights, then it
represented as-
Bias: Bias is a constant that is added to the product of inputs and
weights to calculate the product.
Bias is used to shift the result to the positive or negative side. The
net input weight is increased by a positive bias while The net input
weight is decreased by a negative bias.
ANN: Terminologies
Here,{1, x1 , · · · xn } are the inputs, and the output (Y) neurons will
be computed by the function g(x) which sums up all the input and
adds bias to it. g(x)= xi wi +b where i=1 to n = x1 w1 +· · · +xn wn +b
P
The choice of activation functions determines the neuron model. Few Examples
are-
Neuon Models
Neuon Models
Neuon Models
Basic Learning Laws
Delta Learning: It was introduced by Bernard Widrow and Marcian Hoff and is
also known as Least Mean Square Method. It reduces the error over the entire
learning and training process. In order to minimize error, it follows the gradient
descent method in which the Activation Function continues forever.
Outstar Learning: It was first proposed by Grossberg in 1976, where we use the
concept that a Neural Network is arranged in layers, and weights connected
through a particular node should be equal to the desired output resulting in
neurons that are connected with those weights.
Basic Learning Laws: Unsupervised learning
FFNN is a more general network architecture, where there are hidden layers
between input and output layers.
Hidden nodes do not directly receive inputs nor send outputs to the external
environment.
FFNNs overcome the limitation of single-layer NN.
They can handle non-linearly separable learning tasks.
Multi layer feed-forward NN (FFNN)
The ANN for XOR has two hidden nodes that realizes this non- linear separation
and uses the sign (step) activation function.
Arrows from input nodes to two hidden nodes indicate the directions of the
weight vectors (1,-1) and (-1,1).
The output node is used to combine the outputs of the two hidden nodes.
FFNN Neuron Model
The classical learning algorithm of FFNN is based on the gradient
descent method.
For this reason the activation function used in FFNN are
continuous functions of the weights, differentiable everywhere.
The activation function for node i may be defined as a simple form
of the sigmoid function in the following manner
Feed Backward Architecture: BackPropogation
Algorithm
The AI Problems
AI is developing with such an incredible speed, sometimes it seems
magical.
There is an opinion among researchers and developers that AI
could grow so immensely strong that it would be difficult for humans
to control.
Humans developed AI systems by introducing into them every
possible intelligence they could, for which the humans themselves
now seem threatened.
Module 2: The AI Problems
The AI Problems
Threat to Privacy: An AI program that recognizes speech and
understands natural language is theoretically capable of
understanding each conversation on e-mails and telephones.
Threat to Human Dignity: AI systems have replaced the human
beings in few industries. It should not replace people in the sectors
where they are holding dignified positions which are pertaining to
ethics such as nursing, surgeon, judge, police officer, etc.
Threat to Safety: The self-improving AI systems can become so
mighty than humans that could be very difficult to stop from
achieving their goals, which may lead to unintended consequences.
Bias and Discrimination: AI systems can perpetuate and amplify
human biases, leading to discriminatory outcomes.
Lack of Transparency: AI systems can be difficult to understand
and interpret, making it challenging to identify and address bias and
errors.
Regulation: There is a need for clear and effective regulation to
ensure the responsible development and deployment of AI.
The underlying assumption
The key to the Minimax algorithm is a back and forth between the two players,
where the player whose ”turn it is“ desires to pick the move with the maximum
score. In turn, the scores for each of the available moves are determined by the
opposing player deciding which of its available moves has the minimum score.
And the scores for the opposing players moves are again determined by the
turn-taking player trying to maximize its score and so on all the way down the
move tree to an end state. A description for the algorithm, assuming X is the
"turn taking player," would look something like:
–If the game is over, return the score from X’s perspective.
–Otherwise get a list of new game states for every possible move
–Create a scores list
–For each of these states add the minimax result of that state to the scores list
–If it’s X’s turn, return the maximum score from the scores list
–If it’s O’s turn, return the minimum score from the scores list
–this algorithm is recursive, it flips back and forth between the players until a final
score is found.
Tic-Tac-Toe MinMax Algo Description
It’s X’s turn in state 1. X generates the states 2, 3, and 4 and calls minimax on those states.
State 2 pushes the score of +10 to state 1’s score list, because the game is in an end state.
State 3 and 4 are not in end states, so 3 generates states 5 and 6 and calls minimax on them, while state 4 generates
states 7 and 8 and calls minimax on them.
State 5 pushes a score of -10 onto state 3’s score list, while the same happens for state 7 which pushes a score of -10
onto state 4’s score list.
State 6 and 8 generate the only available moves, which are end states, and so both of them add the score of +10 to the
move lists of states 3 and 4.
Because it is O’s turn in both state 3 and 4, O will seek to find the minimum score, and given the choice between -10 and
+10, both states 3 and 4 will yield -10.
Finally the score list for states 2, 3, and 4 are populated with +10, -10 and -10 respectively, and state 1 seeking to
maximize the score will chose the winning move with score +10, state 2.
N Queens Problem using Backtracking without
Bounding Condition
N Queen problem demands us to place N queens on a N x N chessboard so that
no queen can attack any other queen directly.
Queen can attack other queen in horizontal row, Vertical coloumn or in digonal
direction.
Problem Statement: We need to find out all the possible arrangements in which
N queens can be seated in each row and each column so that all queens are
safe. The queen moves in any of these 8 directions and can directly attack other
queen in these 8 directions only.
N Queens Problem using Backtracking without
Bounding Condition
For Simplicity instead on N queen we consider 4 queen problem
with 4x4 chess board.
4 - Queen Problem: This problem demands us to put 4 queens on
4 X 4 chessboard in such a way that one queen is present in each
row and column and no queen can attack any other queen directly.
this means no 2 or more queens can be placed in the same
diagonal or row or column, total combinations 16C4.
N Queens Problem using Backtracking without
Bounding Condition
Now again the same problem occurs, there left no box to place
Q4. There was only 1 way to place Q3 and all placements of Q2
have been explored, so now we come to Q1 for re-adjustment. We
move it from (0,0) to (0,1). The path so far is | (0,1)|.
N Queens Problem using Backtracking without
Bounding Condition
We put Q2 at (1,0). The path so far is | (0,1) -> (1,0)|. Q3 is put at (2,2). The
path so far is | (0,1) -> (1,0) -> (2,2)|. Now again there is no space left for
placement of Q4 in row 4. Therefore we again backtrack and readjust position of
Q2 from (1,0) to (1,3).The path so far is | (0,1) -> (1,3)|. Q3 is put at (2,0). The
path so far is | (0,1) -> (1,0) -> (2,0)|. We put Q4 at (3,2). The path so far is |
(0,1) -> (1,0) -> (2,0) -> (3,2)|. Therefore through backtracking, we reached a
solution where 4 queens are put in each row and column so that no queen is
attacking any other on a 4 X 4 chessboard.
4-queens Prob With Bounding Function State Space
Tree
Now we solve the problem with bounding function (which is a condition), that
Queens should not be in
– same row
— same column and
–same diagonal
Now, we place queen q1 in the very first acceptable position (1, 1). Next, we put
queen q2 so that both these queens do not attack each other. We find that if we
place q2 in column 1 and 2, then the dead end is encountered. Thus the first
acceptable position for q2 in column 3, i.e. (2, 3) but then no position is left for
placing queen ’q3’ safely. So we backtrack one step and place the queen ’q2’ in
(2, 4), the next best possible solution.
4-queens Prob With Bounding Function State Space
Tree
Then we obtain the position for placing ’q3’which is (3, 2). But later this position
also leads to a dead end, and no place is found where ’q4’ can be placed safely.
Then we have to backtrack till ’q1’and place it to (1, 2) and then all other queens
are placed safely by moving q2 to (2, 4), q3 to (3, 1) and q4 to (4, 3). That is, we
get the solution (2,4, 1, 3). This is one possible solution for the 4-queens
problem. For another possible solution, the whole method is repeated for all
partial solutions. The other solutions for 4 - queens problems is (3, 1, 4, 2) i.e.
State Space Search
The state space search is a process used in the field of computer
science, including artificial intelligence in which succsseive
configurations or states of an instance are considered with the
intension of finding a goal state with the desired property.
There are two types of problem solving in state space search:
Uninformed search and Informed Search
Uninfomed Search: or Brute-force algorithms, search through the
search space all possible candidates for the solution checking
whether each candidate satisfies the problem’s statement.These
are search problem wherein the user is not aware of any doamin
specific problem. For example- Breadth first search, search trees
and so on
Informed Search: These are search search problems wherein the
user is aware of domain specific problem, here we have function
to reach our goal. It uses heuristic functions that are specific to
the problem, apply them to guide the search through the search
space to try to reduce the amount of time spent in searching For
Heuristic Search Techniques: 8-Puzzle Problem
The purpose of heuristic search function is to guide the search in the most
profitable path or optimal path amongst the available path. For complex
problems, the traditional algorithms are unable to find the solutions within some
practical time and space limits. Consequently, many special techniques are
developed, using heuristic functions.
We can explain it by 8-puzzle problem
Heuristic Search Techniques: 8- Puzzle Problem
The purpose of heuristic search function is to guide the search in the most
profitable path or optimal path amongst the available path
Heuristic Search Techniques: 8- Puzzle Problem
The purpose of heuristic search function is to guide the search in the most
profitable path or optimal path amongst the available path
Heuristic Search Techniques: 8- Puzzle Problem
The purpose of heuristic search function is to guide the search in the most
profitable path or optimal path amongst the available path
Production Systems in AI
Here the initial state is (0, 0). The goal state is (2, n) for any value
of n.
State Space Representation: we will represent a state of the
problem as a tuple (x, y) where x represents the amount of water
in the 4-gallon jug and y represents the amount of water in the
3-gallon jug. Note that 0 ≤ x ≤4, and 0 ≤ y ≤ 3. hypothesis.
To solve this we have to make some assumptions not mentioned
in the problem. They are:
– We can fill a jug from the pump.
– We can pour water out of a jug to the ground.
– We can pour water from one jug to another.
– There is no measuring device available.
Operators- we must define a set of operators that will take us from
one state to another.
Production Rules for the Water Jug Problem in
Artificial Intelligence
To solve the water jug problem, many algorithms can be used.
These include:
Breadth-First Search: BFS or Breadth First Search visits the nodes
in order of their distance from the starting node. This implies that it
will visit the nearest node first.
Depth First Search: DFS or Depth First Search visits the nodes in
order of their depth. In production rules for the water jug problem,
let x denote a 4-litre jug, and y denote a 3-litre jug, i.e. x=0,1,2,3,4
or y=0,1,2,3
–Start state (0,0), Goal state (2,n) from any n
DFS is also known as Depth-First Search sometimes turns out to
be an incomplete algorithm and may end up abruptly, giving a
Non-Optimal Solution. The solution generated by the depth-first
search may be incomplete as this algorithm goes on to the deepest
possible point in the first path. In case, that first path leads to
infinity, the algorithm will turn into an infinite loop and will never give
any correct solution.
The Solution to the Water Jug Problem in Artificial
Intelligence
The Solution to the Water Jug Problem in Artificial
Intelligence
Current state (0,0), Loop till the goal state (2,0) is reached.
Apply a rule when the left side matches the current state, Set the
new current state to the resulting state
Start state (0,0) (0, 0)- Start State
(0,3) Apply Rule 2,Fill the 3-litre Jug (4, 0) - Rule 1: Fill the 4-litre jug
(3,0) Apply Rule 9: Pour all the water from a 3-litre jug (1, 3)- Rule 8: Pour water from the 4-litre jug into the
into a 4-litre jug 3-litre jug until the 3-litre jug is full.
(3,3) Apply Rule 2, Fill the 3-litre Jug (1, 0) - Rule 6: Empty the 3-litre jug on the ground
(4,2) Apply Rule 7: Pour water from a 3-litre jug into a (0, 1) -Rule 10: Pour all the water from the 4-litre jug
4-litre jug until it is full into the 3-litre jug.
(0,2) Apply Rule 5, Empty 4-litre jug on the ground (4, 1) - Rule 1: Fill the 4-litre jug
(2,0) Apply Rule 9: Pour all the water from a 3-litre jug (2, 3)- Rule 8: Pour water from the 4-litre jug into the
into a 4-litre jug 3-litre jug until the 3-litre jug is full.
Production Rules for Water Jug Problem
Search Graph Problem for Water Jug Problem
In heuristic search techniques problems, the search proceeds using current information
about the problem to predict which path is closer to the goal and follow it, although it does
not always guarantee to find the best possible solution. Such techniques help in finding a
solution within reasonable time and space (memory).
Some prominent intelligent search algorithms are stated below:
Breadth-first search: A Search strategy, in which the highest layer of a decision
tree is searched completely before proceeding to the next layer is called Breadth-first
search (BFS).
– In this strategy, no viable solutions are omitted and therefore it is guaranteed that
an optimal solution is found.
–This strategy is often not feasible when the search space is large.
– Advantages: i) Guaranteed to find an optimal solution (in terms of shortest number
of steps to reach the goal).
–Advantages: ii) Can always find a goal node if one exists (complete).
–Disadvantages: High storage requirement: exponential with tree depth
Heuristic search techniques: Search Algorithms in AI
Cont...
Depth-first search: A search strategy that extends the current path as far as possible
before backtracking to the last choice point and trying the next alternative path is called
Depth-first search (DFS).
– This strategy does not guarantee that the optimal solution has been found.
– In this strategy, search reaches a satisfactory solution more rapidly than breadth first, an
advantage when the search space is large.
–Advantages: i) Low storage requirement: linear with tree depth.
–Advantages: ii)Easily programmed: function call stack does most of the work of
maintaining state of the search.
–Disadvantages: i) May find a sub-optimal solution (one that is deeper or more costly than
the best solution).
–Disadvantages: ii) Incomplete: without a depth bound, may not find a solution even if one
exists.
Bounded depth-first search: Depth-first search can spend much time (perhaps infinite
time) exploring a very deep path that does not contain a solution, when a shallow solution
exists. An easy way to solve this problem is to put a maximum depth bound on the search.
Beyond the depth bound, a failure is generated automatically without exploring any deeper.
Heuristic search techniques: Search Algorithms in AI
Cont...
Generate-And-Test Algorithm: Generate-and-test search algorithm is a very simple
algorithm that guarantees to find a solution if done systematically and there exists a
solution.
Algorithm:
–Generate a possible solution.
–Test to see if this is the expected solution.
–If the solution has been found quit else go to step 1.
Potential solutions that need to be generated vary depending on the kinds of problems. For
some problems the possible solutions may be particular points in the problem space and
for some problems, paths from the start state.
Generate-and-test, like depth-first search, requires that complete solutions be generated
for testing. In its most systematic form, it is only an exhaustive search of the problem
space. Solutions can also be generated randomly but solution is not guaranteed.
Heuristic search techniques: Search Algorithms in AI
Cont...
If we are looking for a sequence of actions to achieve some goal, one way is to use state
space search where each node in state space search is a state of the world and we serach
for the sequence of actions which help us to reach from start state to goal state.
And-OR-Graph
AND-OR graph is useful for representing the solution of problems that can be solved by
decomposing them into a set of smaller problems all of which must be solved.
It uses a single structure G. G represents the part of the search graph generated so far.
Each node in G points down to its immediate successors and up to its immediate
predecessors, and also has with it the value of h’ cost of a path from itself to a set of
solution nodes.
Algorithm for AND-OR graph
–Step1: Initilize the graph to the starting node
–Step 2: Loop untill starting node is labelled or solved or untill cost leads to the optimal
path
–Step 3:Traverse the graph and set of nodes that are on path and have not been expanded
& labelled as solved
–Step 4:Pick one of these unexpanded nodes and expand it to compute F.
–Step 5:Change the f’ estimate of newly expanded node to reflect the new information by
its successor
Constraint Satisfaction Problem (CSP)
This form of representation is the basis of most of the programming languages we know of
where we use semantics to convey information, and this form is highly logical.
However, the downside of this method is that due to the strict nature of representation
Semantic Networks
In this form, a graphical representation conveys how the objects are connected and are
often used with a data network. The Semantic networks consist of node/block (the objects)
and arcs/edges (the connections) that explain how the objects are connected.
This form of representation is also known as an alternative to the FPOL form of
representation. The relationships found in the Semantic Networks can be of two types -
IS-A and instance (KIND-OF). This form of representation is more natural than logical.
It is simple to understand however suffers from being computationally expensive and do
not have the equivalent of quantifiers found in the logical representation.
Prodection Rules
It is simple if-else rule-based system and, in a way, is the combination of Propositional and
FOPL logics.
This system comprises a set of production rules, rule applier, working memory, and a
recognize act cycle.
For every input, conditions are checked from the set of a production rule, and upon finding
a suitable rule, an action is committed.
This cycle of selecting the rule based on some conditions and consequently acting to solve
the problem is known as a recognition and act cycle, which takes place for every input.
This method has certain problems, such as the lack of gaining experience as it doesn’t
store the past results and can also be inefficient as, during execution, many other rules
may be active.
Frame Representation
At a fundamental level, frames can be imagine as a table having column names and values
in rows and information being passed in this structure.
However, the proper understanding is that it is a collection of attributes and values linked to
it. This AI-specific data structure uses slots and fillers (i.e., slot values, which can be of any
data type and shape).
It has a similar concept to how information is stored in a typical DBMS. These slots and
fillers form a structure - a frame. The slots here have the name (attributes), and knowledge
related to it is stored in the fillers.
The biggest advantage of this form of representation is that due to its structure, similar
data can be combined in groups as frame representation can divide the knowledge in
structures and then further into sub-structures.
Also, being like any typical data structure can be understood, visualized, manipulated
easily, and typical concepts such as adding, removing, deleting slots can be done
effortlessly.
Implicit and Explicit Knowledge
Acquisitional Efficiency: Moreover, The ability to acquire new knowledge using automatic
methods wherever possible rather than reliance on human intervention.
Procedural Knowledge
Knowledge Representation Schemes: Relational
Knowledge
The simplest way to represent declarative facts is a set of relations of the same sort used
in the database system.
Provides a framework to compare two objects based on equivalent attributes. Any instance
in which two different objects are compared is a relational type of knowledge.
The table below shows a simple way to store facts.
– Also, The facts about a set of objects are put systematically in columns.
–This representation provides little opportunity for inference.
Given the facts, it is not possible to answer a simple question such as: “Who is the
heaviest player?”
Also, But if a procedure for finding the heaviest player is provided, then these facts will
enable that procedure to compute an answer.
Moreover, We can ask things like who “bats -left” and “throws - right”.
Knowledge Representation Schemes: Inheritable
Knowledge
Here the knowledge elements inherit attributes from their parents, hierarchical structure.
The knowledge embodied in the design hierarchies found in the functional, physical and
process domains.
Within the hierarchy, elements inherit attributes from their parents, but in many cases, not
all attributes of the parent elements prescribed to the child elements.
Also, The inheritance is a powerful form of inference, but not adequate. Moreover, The
basic KR (Knowledge Representation) needs to augment with inference mechanism.
Property inheritance: The objects or elements of specific classes inherit attributes and
values from more general classes.
So, The classes organized in a generalized hierarchy.
Knowledge Representation Schemes: Inheritable
Knowledge Cont..
A representation in which the control information, to use the knowledge, embedded in the
knowledge itself. For example, computer programs, directions, and recipes; these indicate
specific use or implementation;
Moreover, Knowledge encoded in some procedures, small programs that know how to do
specific things, how to proceed.
Advantages:
– Heuristic or domain-specific knowledge can represent.
–Moreover, Extended logical inferences, such as default reasoning facilitated.
–Also, Side effects of actions may model. Some rules may become false in time.
–Keeping track of this in large systems may be tricky.
Disadvantages:
–Completeness - not all cases may represent.
–Consistency - not all deductions may be correct. e.g If we know that Fred is a bird we
might deduce that Fred can fly. Later we might discover that Fred is an emu.
–Modularity sacrificed. Changes in knowledge base might have far-reaching effects.
Cumbersome control information.
Logic Representation: Representation of Simple Facts
in Logic
AI system need to represent knowledge. Two types of knowledge representation:
–Propositional Logic
–Predicate Logic (First Order Predicate Logic)
Propositional Logic
Propositional logic is one of the fairly good forms of representing the same because it is
simple to deal with and a decision procedure for it exists. Real-world facts are represented
as logical propositions and are written as well-formed formulas in propositional logic exists.
Also, In order to draw conclusions, facts are represented in a more convenient way as-
1. Marcus is a man,
represented as- man(Marcus)
2. Plato is a man
represented as- man(Plato)
3. All men are mortal.
represented as- mortal(men)
But propositional logic fails to capture the relationship between an individual being a man
and that individual being a mortal.
Propositional Logic
Propositional logic is a formal language that uses symbols to represent propositions and
logical connectives to combine them. The symbols used in propositional logic include
letters such as p, q, and r, which represent propositions, and logical connectives such as ∧
(conjunction), ∨ (disjunction), and (negation), which are used to combine propositions.
An statement is a proposition if it is either true or false. Examples of propositions include
“2+2=4,“ and “The sky is blue.“
Logical connectives are used to combine propositions to form more complex statements.
Truth tables are used to represent the truth values of propositions and the logical
connectives that combine them.
In propositional logic, inference rules are used to derive new propositions from existing
ones. Propositional logic is a limited form of logic that only deals with propositions that are
either true or false.
Summarized table for Propositional Logic Connectives
In propositional logic, operators are used to combine propositions to form more complex propositions. Here are some of
the properties of operators commonly used in propositional logic: Suppose Set 1: A = {2, 4, 6} B = {3, 6, 9}
Commutativity: The commutative property states that the order in which the operators are applied does not affect the
result. For example, the union of A and B is A ∪ B = {2, 3, 4, 6, 9}, which is the same as the union of B and A, i.e., B ∪ A
= {2, 3, 4, 6, 9}. Therefore, the union operator is commutative.
Associativity: The associative property states that the grouping of operators does not affect the result. For example, the
intersection of A, B, and C is (A ∩ B) ∩ C = {6} ∩ {3, 6, 9} = {6} and A ∩ (B ∩ C) = {2, 4, 6} ∩ {3, 6, 9} = {6}. Therefore,
the intersection operator is associative.
Identity element: The identity element property states that there is an element that can be combined with any other
element using the operator without changing the result. For example, the intersection of A and the universal set U is A ?
U = {2, 4, 6}. Therefore, the universal set is the identity element of the intersection operator.
Distributive: The distributive property states that one operator can be distributed over the other operator. For example,
the intersection operator is distributive over the union operator. That is, A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C). For instance, A
∩ (B ∪ C) = {2, 4, 6} ∩ {3, 6, 7} = {6}, and (A ∩ B) ∪ (A ∩ C) = {2, 4, 6} ∩ {6} ∪ {2, 4, 6} ∩ {3, 7} = {6}.
De Morgan’s Law: De Morgan’s Law states that the complement of the union of two sets A and B is equal to the
intersection of the complement of A and the complement of B. That is, (A ∪ B)’ = A’ ∩ B’. For example, (A ∪ B)’ = {2, 3,
4, 6, 9}’= {1, 5, 7, 8} and A’ ∩ B’ = {1, 3, 5, 7, 8} ∩ {1, 2, 4, 5, 7, 8} = {1, 5, 7, 8}. Therefore, De Morgan’s Law holds.
Double-negation elimination: Double negation elimination is a valid rule of replacement that states that if not not-A is true,
then A is true. For example, if A = {2, 4, 6}, then A”= {2, 4, 6}, which is equivalent to A. Therefore, double negation
elimination holds.
Limitations of Propositional Logic
Example that shows the use of predicate logic as a The facts described by these sentences can be rep-
way of representing knowledge. resented as a set of well-formed formulas (wffs)
1. Marcus was a man. 1. man(Marcus)
5. Also, All Pompeians were either loyal to Caesar or 5. inclusive-or ∀ x: Roman(x) → loyalto(x, Caesar) ∨
hated him. hate(x, Caesar)
exclusive-or ∀ x: Roman(x) → (loyalto(x, Caesar) ∧
¬ hate(x, Caesar)) ∨ (¬loyalto(x, Caesar) ∧ hate(x,
Caesar))
7. People only try to assassinate rulers they are not ∀ x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y) →
loyal to. ¬ loyalto(x, y)
The problem is that, although we know that Marcus was a man, we do not have any way to
conclude from that that Marcus was a person.
Also, We need to add the representation of another fact to our system, namely: ∀ man(x)
→ person(x)
Now we can satisfy the last goal and produce a proof that Marcus was not loyal to Caesar.
Issues which needs to be AddressedFirst Order
Predicate logic Cont..
From the above example, we see that three important issues must be addressed in the
process of converting English sentences into logical statements and then using those
statements to deduce new ones:
Many English sentences are ambiguous (for example, 5, 6, and 7 above). Choosing
the correct interpretation may be difficult.
Similalry, Even in very simple situations, a set of sentences is unlikely to contain all
the information necessary to reason about the topic at hand. In order to be able to
use a set of statements effectively. Moreover, It is usually necessary to have access
to another set of statements that represent facts that people consider too obvious to
mention.
Difference between Propositional Logic and Predicate
Logic
The predicate instance is a binary one, whose first argument is an object and whose second argument is a class to which
the object belongs.
Instance used to show class inclusion e.g. isa(mega_star,rich)
Instance used to show class membership e.g., Instance(prince,mega_star)
But these representations do not use an explicit isa predicate.
Instead, subclass relationships, such as that between Pompeians and Romans, described as shown in sentence 3.
The implication rule states that if an object is an instance of the subclass Pompeian then it is an instance of the
superclass Roman.
Note that this rule is equivalent to the standard set-theoretic definition of the subclass- superclass relationship.
The third part contains representations that use both the instance and isa predicates explicitly.
The use of the isa predicate simplifies the representation of sentence 3, but it requires that one additional axiom (shown
To express simple facts, such as the following greater-than and less-than relationships: gt(1,O) It(0,1) gt(2,1) It(1,2)
gt(3,2) It( 2,3)
It is often also useful to have computable functions as well as computable predicates. Thus we might want to be able to
evaluate the truth of gt(2 + 3,1)
To do so requires that we first compute the value of the plus function given the arguments 2 and 3, and then send the
arguments 5 and 1 to gt.
Consider the following set of facts, again involving Marcus:
1) Marcus was a man.
man(Marcus)
2) Marcus was a Pompeian.
Pompeian(Marcus)
3) Marcus was born in 40 A.D.
born(Marcus, 40)
4) All men are mortal.
x: man(x) → mortal(x)
5) All Pompeians died when the volcano erupted in 79 A.D.
erupted(volcano, 79) ∧ ∀ x : [Pompeian(x) → died(x, 79)]
6) No mortal lives longer than 150 years.
x: t1: At2: mortal(x) ∧ born(x, t1) ∧ gt(t2 - t1,150) → died(x, t2)
7) It is now 1991.
now = 1991
Computable Functions and Predicates
So, Above example shows how these ideas of computable functions and predicates can be useful. It also makes use of
the notion of equality and allows equal objects to be substituted for each other whenever it appears helpful to do so
during a proof.
So, Now suppose we want to answer the question ”Is Marcus alive¿‘
The statements suggested here, there may be two ways of deducing an answer.
Either we can show that Marcus is dead because he was killed by the volcano or we can show that he must be dead
because he would otherwise be more than 150 years old, which we know is not possible.
Also, As soon as we attempt to follow either of those paths rigorously, however, we discover, just as we did in the last
example, that we need some additional knowledge. For example, our statements talk about dying, but they say nothing
that relates to being alive, which is what the question is asking. So we add the following facts:
8) Alive means not dead.
x: t: [alive(x, t) → ¬ dead(x, t)] [ ¬dead(x, t) → alive(x, t)]
9) If someone dies, then he is dead at all later times. x: t1: At2: died(x, t1) ∧ gt(t2, t1)→ dead(x, t2)
Resolution: Resolution in Predicate Logic
The resolution algorithm for predicate logic as follows, assuming a set of given statements F and a statement to be
proved P:
Algorithm: Resolution
1. Convert all the statements of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in 1.
–In logic, a clause is a propositional formula formed from a finite collection of literals (atoms or their negations)
and logical connectives.
3. Repeat until a contradiction found, no progress can make, or a predetermined amount of effort has expanded.
–1. Select two clauses. Call these the parent clauses.
–2. Resolve them together. The resolvent will the disjunction of all the literals of both parent clauses with
appropriate substitutions performed and with the following exception: If there is one pair of literals T1 and ¬T2
such that one of the parent clauses contains T2 and the other contains T1 and if T1 and T2 are unifiable, then
neither T1 nor T2 should appear in the resolvent. We call T1 and T2 Complementary literals. Use the substitution
produced by the unification to create the resolvent. If there is more than one pair of complementary literals, only
one pair should omit from the resolvent.
–3. If the resolvent is an empty clause, then a contradiction has found. Moreover, If it is not, then add it to the set
of classes available to the procedure.
Resolution Procedure
Resolution is a procedure, which gains its efficiency from the fact that it operates on statements that have been converted
to a very convenient standard form.
Resolution produces proofs by refutation (the action of proving a statement or theory to be wrong or false).
In other words, to prove a statement (i.e., to show that it is valid), resolution attempts to show that the negation of the
statement produces a contradiction with the known statements (i.e., that it is unsatisfiable).
The resolution procedure is a simple iterative process: at each step, two clauses, called the parent clauses, are
compared (resolved), resulting in a new clause that has inferred from them. The new clause represents ways that the two
parent clauses interact with each other. Suppose that there are two clauses in the system:
Winter ∨ Summer; ¬Winter ∨ Cold
Now we observe that precisely one of winter and ¬ winter will be true at any point.
If winter is true, then cold must be true to guarantee the truth of the second clause. If ¬ winter is true, then
summer must be true to guarantee the truth of the first clause.
Thus we see that from these two clauses we can deduce summer V cold
This is the deduction that the resolution procedure will make.
Resolution operates by taking two clauses that each contains the same literal, in this example, winter.
Moreover, The literal must occur in the positive form in one clause and in negative form in the other. The
resolvent obtained by combining all of the literals of the two parent clauses except the ones that cancel.
If the clause that produced is the empty clause, then a contradiction has found. For example, the two clauses
winter, and ¬ winter will produce the empty clause.