Artificial Intelligence
Artificial Intelligence
Artificial Intelligence
Early History of AI
Philosophy:- The Three Great
Movement:- empiricism vs rationalism
● It is voluminous.
● It is hard to characterize accurately.
● It is constantly changing.
● It differs organized data corresponds to the ways they used.
i. Thinking humanly
0 1 4 2
4 1 0 2
2 3 2 0
Solution-1 Solution-2
Step Operator Description (Action) Production Rules
3 Pour some water from a 4-litre jug x = 0,1,2,3,4 (x,y) if x>0 → (x-x’, y)
4 Pour some water from a 3-litre jug y = 0,1,2,3 (x,y) if y>0 → (x, y-y’)
7 Pour water from a 3-litre jug into a 4-litre jug until it is full (x,y) if x+y>=4 and y>0 → (4,y-(4-x))
8 Pour water from a 4-litre jug into a 3-litre jug until it is full (x,y) if x+y>=3 and x>0 → (x-(3-y),3)
9 Pour all the water from 3-litre jug into 4-litre jug (x, y) if x+y <=4 and y>0 → (x+y, 0)
10 Pour all the water from 4-litre jug into 3-litre jug (x, y) if x+y <=3 and x>0 → (0,x+y)
11 Pour 2-litre water from 3-litre jug into 4-litre jug (0, 2) → (2,0)
DENDRAL uses forward chaining to create chemical structures. To diagnose bacterial infections, MYCIN
employs the backward chaining technique.
Advantages of Expert Systems Limitations of Expert Systems
antecedent→consequent
condition →action
premise →conclusion
X→Y
Rules can represent:
● Relation: IF the ‘fuel tank’ is empty THEN the car is dead.
● Recommendation: IF the season is autumn AND the sky is cloudy AND the
forecast is drizzle THEN the advice is ‘take an umbrella’
● Directive: IF the car is dead AND the ‘fuel tank’ is empty THEN the action is
‘refuel the car’
● Strategy: IF the car is dead THEN the action is ‘check the fuel tank’; step1
complete IF step1 is complete AND the ‘fuel tank’ is full THEN the action is
‘check the battery’; step2 is complete
● Heuristic: IF the spill is liquid AND the ‘spill pH’ < 6 AND the ‘spill smell’ is
vinegar THEN the ‘spill material’ is ‘acetic acid’
IF the ‘traffic light’ is green
THEN the action is go
R3: IF: engine turns AND engine does not start If the initial facts are “engine does not turn” and
THEN: ask user to check the spark “battery is not flat”, the conflict set is:
R4: IF: engine does not turn { 〈 R1, engine does not turn, battery is not flat 〉,
THEN: ask user to check the battery 〈 R4, engine does not turn 〉 }
1. p ^ q → goal
2. r^s→p
3. w^r→p
4. t^u→q
5. v →s
6. start → v ^ r ^ q
More Examples
Methods used for conflict resolution
If two rules could be chosen:
● Rule Ordering: Arrange all rules in one long priority list. The triggering rule
appearing earliest in the list has the highest priority.
● Refractoriness: If it has matched exactly the same data before and been
chosen, then ignore it. This helps to stop the system getting into infinite loops.
● Specificity: fire the one whose conditions are most specific. E.g. ``it has wings
and swims'' over ``it has wings''. This method is also known as the longest
matching strategy.
● Recency: If two rules could be chosen, fire the one that matches the most
recent facts in the database.
Advantages of rule-based expert systems
● Separation of Knowledge (the Rules) and Control (Recognize-Act Cycle)
● Reduce the Decision-Making Time
● Modularity of Production Rules (Rules represent chunks of knowledge)
● Pattern-Directed Control (More flexible than algorithmic control)
● Opportunities for Heuristic Control can be built into the rules
● Language Independence
● Natural Mapping onto State Space Search (Data or Goal Driven)
Uncertainty Management in Rule-based Expert Systems
● Information can be incomplete, inconsistent,uncertain, or all three (lack of the
exact knowledge).
● Uncertainty can be expressed numerically as certainty/confidence factor (cf)
or measure of belief (mb)
● cf usually is a real number in a particular range, eg, 0 to 1 or -1 to 1
Combining certainties of propositions and rules
Let P1 and P2 be two propositions and cf(P1) and cf(P2) denote their
certainties
Then cf(P1 and P2) = min(cf(P1), cf(P2))
cf(P1 or P2) = max(cf(P1), cf(P2))
Given the rule
if P1 then P2: cf = C
then certainty of P2 is given by cf(P2) = cf(P1) * C
Example
if it rains then John will catch a taxi: cf = 0.6
Suppose cf for ‘it rains’ is 0.5,
then cf of ‘John catching a taxi’ = 0.5 * 0.6 = 0.3
if it rains and I forget the umbrella then I’ll get wet: cf = 0.9
cf of ‘if it rains and I forget the umbrella’ = min(0.7, 0.6) = 0.6
= 0.6 * 0.9
= 0.54
Goal-Driven and Data-Driven Strategies
Goal-driven search uses knowledge of the goal to guide the search. Use goal-driven search if;
● A goal or hypothesis is given in the problem or can easily be formulated.
(Theorem proving; medical diagnosis; mechanical diagnosis)
● There are a large number of rules that match the facts of the problem and would thus
produce an increasing number of conclusions or goals. (inefficient)
● Problem data are not given but must be acquired by the problem solver.
(e.g., medical tests determined by possible diagnosis)
Data-driven search uses knowledge and constraints found in the given data to search along lines
known to be true. Use data-driven search if:
● All or most of the data are given in the initial problem statement.
● There are a large number of potential goals, but there are only a few ways to use the facts
and the given information of a particular problem.
● It is difficult to form a goal or hypothesis.
Problem Solving by Searching
The components that define a problem in AI
Initial state: The state from which the agent infers that it is at the beginning.
Successor function: Description of possible actions and their outcome.
Given a state x,SUCCESSOR-FN(x)Returns a set of < action,successor> ordered
pairs.
A path from an initial state to a goal state is a solution.
The initial state and successor function define the state space.
Path cost: Assigns numeric cost to each path.Step cost for taking action a from
state x to y-denoted by c(x,a,y).
Goal test : Whether the given state is a goal state?
Which of the following is not a component of AI Problem?
(a) Initial State
(b) Successor function or Action
(c) Goal test
(d) Determining start state
Well-defined Problem: have clear starting and ending point.(initial and goal)
Ill-defined Problem: have ambiguity on initial and goal state. E.g How to
enjoy a Happy life?
Methods of Problem Solving: a) trial and Error b) algorithm c) heuristics
Problem Characteristics
● Is the problem decomposable into small sub-problems which are easy to solve?
● Can solution steps be ignored or undone?
● Is the universe of the problem is predictable?
● Is a good solution to the problem is absolute or relative?
● Is the solution to the problem a state or a path?
● What is the role of knowledge in solving a problem using artificial intelligence?
● Does the task of solving a problem require human interaction?
Problem Solving by Searching
- Searching is core of many intelligent process
- State space = {all possible configurations}
(3,62,880 different configurations of the 8 tiles and blank space.)
- Concept: finding information one needs.
- The process of problem-solving using
searching consists of the following steps.
● Define the problem
● Analyze the problem
● Identification of possible solutions
● Choosing the optimal solution
● Implementation
Control/Search Strategies
● The first requirement for a good control strategy is that it should cause motion.
● The second requirement for a good control strategy is that it should be systematic.
● Finally, it must be efficient in order to find a good answer.
Evaluate performance of Search algorithm
-
-
-
-
-
- Consider uniform tree where every state has b successors.
- b + b2 + b3 + ··· + bd = O(bd)
- O(bd−1) nodes in the explored set and O(bd) nodes in the frontier: Space?
- memory requirements are a bigger problem for BFS than is the execution time.
- exponential-complexity search problems cannot be solved by uninformed methods
for any but the smallest instances.
Breadth-first search
Breadth First Search: Example
Breadth First Search: Example
S 1
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C
2 E
5 7 7
G1
G3
8
G2 F
A ✔ B D A 2 9
6
D
3 2
2
9 1
B
B G1 C
2 E
5 7 7
G1
G3
8
G2 F
A ✔ B D A 2 9
6
D
3 2
2
9 1
B
B G1 A C C
2 E
5 7 7
G1
G3
8
G2 F
✔
A ✔ B D A 2 9
6
D
3 2
2
9 1
B
B G1 A C C
2 E
5 7 7
G1
G3
8
G2 F
✔
A ✔ B D A 2 9
6
D
3 2
2
9 1
B
B G1 A C C E S C
2 E
5 7 7
G1
G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
9 1
B
B G1 A C C E S C
2 E
5 7 7
G1
G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
9 1
B
B G1 A C C E S C
2 E
5 7 7
G1
A C G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ 9 1
B
B G1 A C C E S C
2 E
5 7 7
G1
A C G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ ✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ ✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ ✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
Path: S A G1
Referred from John Levine
Breadth First Search: Example
S 1
S ✔
5 6
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ ✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
Path: S A G1
Path cost: 14 Referred from John Levine
Breadth First Search: Example
S 1
S ✔
5 6
✔
A ✔ B D ✔ A 2 9
6
D
3 2
2
✔ ✔ 9 1
B
B G1 A C C E S C
2 E
GOAL
5 7 7
G1
A C G3
8
G2 F
Path: S A G1
Path cost: 14 Referred from John Levine
Breadth First Search: Example with less work
Visited Nodes Empty S 1
S
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
DEAD
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
DEAD
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
DEAD GOAL
5 7 7
G1
G3
8
G2 F
A B D A 2 9
6
D
3 2
2
9 1
B
B G1 C C E C
2 E
DEAD GOAL
5 7 7
G1
G3
8
G2 F
Path: S A G1
Path cost: 14 Referred from John Levine
Depth-first search
Depth First Search: Example
S 1
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
6
C D
A 2
3
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
6
C D
A 2
3
2
9 1
A already explored B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
9 1
B
F G2 S C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
9 1
B
F G2 S C
2 E
S already explored
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
G1
G3
8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
G1
G3
C E S 8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
G1
G3
C E S 8
G2 F
C already explored
Referred from John Levine
Depth First Search: Example
S
S 1
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
❌ G1
G3
C E S 8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
❌ G1
G3
C E S 8
G2 F
A B D 5 6
B G1
A 2 9
❌ 6
C D
A 2
3
2
❌ 9 1
B
F G2 S C
2 E
D G3 5 7 7
❌ G1
G3
C E S 8
G2 F
5 6
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
A 2 9
6
D
3 2
2
9 1
B
C
2 E
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
G1
G3
8
G2 F
5 7 7
1
G1
G3
8
C G2 F
5 7 7
1
G1
G3
8
C 9 G2 F
5 7 7
1
G1
G3
8
C 9 G2 F
5 7 7
1 7 5 G1
G3
8
C 9 F G2 G2 F
5 7 7
1 7 5 G1
G3
8
C 9 F G2 G2 F
15 13
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C,
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 G1
G3
8
C 9 F G2 G2 F
15 13
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 DEAD 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 DEAD 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 DEAD 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
GOAL Referred from John Levine
Uniform-cost search
S 1
S Visited: S, A, D, B, C, E
5 6
5 9 6
A 2 9
6
A 5 B 9 D 6 D
3 2
3 9 DEAD 2 2 2
9 1
B
C
B 8 G1 14 C 8 E 8 2 E
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Uniform-cost search
- Time Complexity:
Let C* is Cost of the optimal solution, and ε is each step to get closer to the goal node. Then the number of steps is
= C*/ε+1. Here we have taken +1, as we start from state 0 and end to C*/ε.
Hence, the worst-case time complexity of Uniform-cost search is O(b1 + [C*/ε]).
- Space Complexity:
The same logic is for space complexity so, the worst-case space complexity of Uniform-cost search is O(b1 + [C*/ε]).
5 7 7
1 7 5 7
G1
G3
8
C 9 F G2 G3 G2 F
15 13 15
DEAD
Referred from John Levine
Depth limited Search
Step 2: Loop Until a solution is found or there is no new operator left to apply.
Step 5: Exit.
Problems with Hill Climbing
Ridge
Topographical (contour) maps
A line of high ground with height variations along its crest. The ridge is not simply
a line of hills; all points of the ridge crest are higher than the ground on both sides
of the ridge.
Usually contour lines close together with two ends which are visible will form a
ridge. If it is a valley, there will often be some form of watercourse In it (drainage).
If contour lines are close together in a a circular (or approximate) shape, it’s
usually a hill.
A continuous elevated terrain with sloping sides. In the map represented by “U” or
“V” shaped contour lines where the higher ground is in the wide opening
Problems with Hill Climbing: Local maximum
A state better than all neighbours but not better than some other states farther
away.
When considering the actual cost along with the inequality h(n) <= h*(n) for all n in
the search space, it strictly an A* search. We explain it in the later slides by taking
graph.
Example for Best First Search and A*(always h(n)<= h*(n))
A* Algorithm continued from Best First Search
f(n)
For A* Algorithm, Use a heuristics which is always h(n) <= h*(n) for all n in the search tree.
A* Algorithm
- This h(n) function is an admissible heuristic because the h value is less than or equal to the actual/exact
cost of a lowest-cost path from the node to a goal.
- Or h(n) never overestimates the true cost from node n to a goal node
- Consistent if its estimate to reach the target is always less than or equal to the sum of estimated cost
from any of its neighboring points and the cost of reaching that neighbor from current position.
- consistent, or monotone, if its estimate is always less than or equal to the estimated distance from any
neighbouring vertex to the goal, plus the cost of reaching that neighbour.
- A consistent heuristic is also admissible, i.e. it never overestimates the cost of reaching the goal
′ ′
h(n) <= C(n,n ) + h(n )
OR ′
h(n) - h(n ) <= C(n,n′)
Underestimation: actual price is higher than your estimated price h(n) ≤ h*(n)
Prepare
Study Do
ASTU
Hard Cheating
Notes
AO* (Adaptive Optimal) Algorithm
- Best-first search algorithm (Informed)
- Based on AND-OR graphs to break complex problems
- Evaluation function: f(n) = g(n) + h(n)
- "* " symbolize that the algorithm is iterative
- Objective: find the optimal solution while minimizing computation
- Explore a solution path
-
Correcting
Reachingthe Path
Last fromand
Label
Forward
Start Node Propagation
Back propagation
Practice
Comparison A* and AO*
- Both works on the best first search.
- Once AO* got a solution doesn’t explore all possible paths but A* explores all
paths.
- A* always gives the optimal solution but AO* doesn't guarantee to give the
optimal solution.
- AO* algorithm uses less memory.
Problem Reduction Search
- Is a Planning to solve a Complex problem
- Recursively decomposed into many sub-problems
- Top Down Approach
- P—-----> P1XP2XP3…PN
–> P1(P2XP3) or (P1XP2)P3 or …
- Example Matrix Multiplication
- Example: Tower of Hanoi P Q R Move all disks from P to R using Q
T(n,P,R)---> T(n-1,P,Q) and T(1, P,R) and T(n-1,Q,R)
Beyond Classical Search
● Local search
● Generate and Test
● Hill Climbing
● Problem reduction
● Constraint satisfaction
● Simulated annealing
● Local beam search
● Means-ends analysis
Sub-Problem Relationship
- AND-OR
- OR node: represents choice between decompositions.
- AND node: represents a given decomposions.
- MIN-MAX: MAX: Choice of my opponent and MIN: My choice
Problem Reduction
Problem Reduction
Problem Reduction
Beam Search
- Beam Search 2
Genetic Algorithm
- Reference(Chapter01-16)
Examples
- Grass is green. - Close the door.
- 2+5=5 - Is it hot outside ?
- x is greater than 2.
- x=x
- 3=3
- Wine = Wine
Compound Statement
How statements can be combined to produce new statements?
Meaning of the Connectives
(A B) ∧ A B
Modus Ponens: Examples
1. If your is in checkmate then you have lost the game.
2. Your king is in checkmate .
Therefore, you have lost the game.
1. If today is Wednesday, then Jyoti will go to school.
2.Today is Wednesday .
Therefore, Jyoti will go to school.
1. If I do the dishes, then my wife will be happy with me.
2. I do the dishes .
Therefore, my wife is happy with me.
Modus Ponens: Exercise
If Priyanka is at home, the home will be quiet and if the home is quiet or it is
Sunday it’s easy to relax. Prove that it’s easy to relax.
P: Priyanka is at home.
Q: The home is Quiet.
S: It is Sunday.
R: It’s easy to Relax.
Premises:
1. P Priyanka is at home. Given
2. P Q If Priyanka is at home, the home will be quiet. Given
3. (Q ∨ S) R if the home is quiet or it is Sunday it’s easy to relax. Given
4. Q It’s easy to relax. Modus Ponens ([1][2])
Modus Ponens: Exercise
Premises: P, P Q and (Q ∨ S) R
Conclusion: R
1. P Given
2. P Q Given
3. (Q ∨ S) R Given
4. Q Modus Ponens ([1][2])
5. Q ∨ S Addition [4]
6. R Modus Ponens ([3][5])
Modus Tollens (the mode that denies)
1. If you have a current password, then you can log on to the network.
2. You have a current password.
Therefore, you can log on to the network.
You can't log into the network
If you have a current password, then you can log into the network.
Therefore, you don't have a current password.
¬q
p→q
¬p
Note:- In logic problems take the statements literally and at face value.
Universal forms: modus ponens and modus tollens
∀x((P(x)→Q(x))
P(a), where a ∈ {domain of the predicate P}
Q(a)
E.g. All fish have scales. This salmon is a fish. Therefore, this salmon has scales.
All men are mortal. Jyoti is a man. Therefore, Jyoti is mortal.
∀x((P(x)→Q(x))
¬Q(a), where a ∈ {domain of the predicate P}
¬P(a)
E.g. All surfers are hot. Conrad is not hot. Therefore Conrad is not a surfer.
Conversion English Sentence into logical statements
Sentence into WFF
1. Marcus was a man. 1. man(Marcus).
2. Marcus was a Pompeian. 2. man(Pompeian)
3. All Pompeians were Roman. 3. ∀x [ pompeian(x) → roman(x)]
4. Caesar was a ruler. 4. ruler(Caesar)
5. All Romans were either loyal to Caesar or 5. ∀x [ Roman(x) → loyalto(x, Caesar)∨hate(x,
hated him. Caesar)]
6. Everyone is loyal to someone. 6. ∀x ∃y [loyalto(x,y)]
7. People only try to assassinate rulers they 7. ∀x ∀y [ person(x) ∧ ruler(y)
are not loyal to. ∧tryassassinate(x,y) →¬loyalto(x,y) ]
8. Marcus tried to assassinate Caesar. 8. tryassassinate(Marcus,Caesar)
Was Marcus loyal to Caesar ?
Using 7 and 8 we can able to prove it (ignoring the tenses)
A formal attempt to prove by using backward reasoning (from goal)
↑ (7, substitution)
person(Marcus)
ruler(Caesar)
tryassassinate(Marcus,Caesar)
↑ (4)
person(Marcus)
tryassassinate(Marcus,Caesar)
↑ (8)
person(Marcus)
Was Marcus loyal to Caesar ?
Now we can satisfy the last goal and produce proof that Marcus was not loyal to Caesar.
If a statement if false negation of that is true and vice versa.
Computable predicate and resolution tree (for proof)
Turing Machine: Computable function
3 ways of representing Class Membership: Instance and Isa
- Class membership - Instance predicate - Isa predicate derives
represented with unary represented with binary subclass-superclass relationship.
predicates. If an object is instance of
Instance(object,class) subclass then it is an instance of
superclass.(requires extra axiom)
1. instance(Marcus, man)
1. man(Marcus) 1. instance(Marcus, man)
2. instance(Marcus, Pompeian)
2. Pompeian(Marcus) 2. instance(Marcus, Pompeian) 3. Pompeian is a subclass
3. ∀x [ pompeian(x) → 3. ∀x [ instance(x, pompeian) → Roman is a superclass
roman(x)] instance(x, roman)] isa(Pompeian, Roman)
4. ruler(Caesar) 4. instance (Caesar, ruler) 4. instance (Caesar, ruler)
5. ∀x [ Roman(x) → loyalto(x, 5. ∀x [ instance(x,Roman) → 5. ∀x [ instance(x,Roman) →
Caesar)∨hate(x, Caesar)] loyalto(x, Caesar)∨hate(x, loyalto(x, Caesar)∨hate(x,
Caesar)] Caesar)]
6. ∀x∀y∀z [instance(x,y)
∧isa(y,z) →instance(x,z)]
Points to ponder on class membership representation
- Although class and superclass memberships are important facts for
representations, need not be represented with instance and Isa predicates.
- Usually several different ways of representing a given fact within a particular
representational framework. (deduction and test)
- Many errors in reasoning performed by KB programs are the results of
inconsistent representation decisions.
- Isa hierarchies is used in many logic-based systems.
Facts involving Marcus
1. Marcus was a man. 1. man (Marcus)
2. Marcus was a Pompeian. 2. Pompeian (Marcus)
3. Marcus was born in 40 A.D. 3. born(Marcus, 40)
4. All men are mortal. 4. ∀x [ man(x) → mortal(x)]
5. All Pompeians died when volcano erupted 5. erupted(volcano, 79) ∧∀x [(Pompeian(x) → died(x, 79))]
in 79 A.D. 6. ∀x: ∀t1:∀t2 [mortal(x) ∧born(x, t1 ) ∧ gt(t2- t1, 150) →
6. No mortal lives longer than 150 years. dead(x, t2))] [gt is a computable predicates]
7. It is now 2023. 7. now = 2023
8. Alive means not dead. 8. ∀x: ∀t [alive(x,t) → ¬ dead (x,t)] ∧[¬ dead (x,t) →
9. If someone dies, then he is dead at all alive(x,t)]
later times. 9. ∀x: ∀t1:∀t2 [died(x,t1) ∧ gt(t2 , t1) → dead(x, t2)]
Is Marcus alive ? Summary of facts about Marcus
Negate the goal: ¬ alive(Marcus, now)
1. man (Marcus)
↑ (8, substitution) [Marcus/x, now/t] 2. Pompeian (Marcus)
dead(Marcus,now) 3. born(Marcus, 40)
4. ∀x [ man(x) → mortal(x)]
↑ (9, substitution) [Marcus/x,now/t2] 5. erupted(volcano, 79) ∧
died(Marcus, t1) ∧ gt(now , t1) ∀x [(Pompeian(x) → died(x, 79))]
6. ∀x: ∀t1:∀t2 [mortal(x) ∧born(x, t1 ) ∧
↑ (5, substitution) [Marcus/x,79/t1]
gt(t2- t1, 150) → dead(x, t2))]
Pompeian(Marcus )∧ gt(now , 79) 7. now = 2023
8. ∀x: ∀t [alive(x,t) → ¬ dead (x,t)] ∧
↑ (2)
[¬ dead (x,t) → alive(x,t)]
gt(now , 79) 9. ∀x: ∀t1:∀t2 [died(x,t1) ∧ gt(t2 , t1) →
dead(x, t2)]
↑ (7, substitution)
gt(2023 , 79)
↑ (compute gt)
NIL [empt list for proof]
Is Marcus alive ? (Another way) Summary of facts about Marcus
Negate the goal: ¬ alive(Marcus, now)
↑ (compute subtraction)
gt(1983 , 150)
↑ (compute gt)
¬p∧¬q∨r: neither
Conjunctive Normal Form (CNF)
All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is crazy.
WFF: ∀x [Roman(x) ∧ know(x, Marcus)]→[hate(x, Caesar) ∨ ∀y: ∃z: (hate(y,z) → thinkcrazy(x,y)) ]
∀x: [¬ [Roman(x) ∧ know(x, Marcus)] ] ∨ [hate(x, Caesar) ∨ ∀y: ∃z: (hate(y,z) → thinkcrazy(x,y)) ]
∀x: [¬ Roman(x) ∨ ¬ know(x, Marcus)] ∨ [hate(x, Caesar) ∨ ∀y: ∃z: (hate(y,z) → thinkcrazy(x,y)) ]
∀x: [Roman(x) ∧ know(x, Marcus)]∨ [hate(x, Caesar) ∨ ∀y: ∃z: (¬hate(y,z) ∨ thinkcrazy(x,y)) ]
1. Eliminate Implications:
∀x: ¬ [Roman(x) ∧ know(x, Marcus)]∨[hate(x, Caesar) ∨ ∀y: ∃z (hate(y,z) → thinkcrazy(x,y)) ]
3. Standardize the variables in each of the quantifier that binds a unique variable.
∀x P(x) ∨ ∀x Q(x) converted to ∀x P(x) ∨ ∀y Q(y)
4. Move all quantifiers to the left of the formula without changing the relative order
∀x ∀y ∃z [¬Roman(x) ∨¬ know(x, Marcus)]∨[hate(x, Caesar) ∨¬(hate(y,z) ∨ thinkcrazy(x,y)) ]
9. Standardize apart the variables in the set of clauses so that no two clauses make references to the same variable.
Prenex Normal Form (PNF)
All quantifiers appear at the beginning of the formula
Example: Find equivalent PNF of F : ∀x. ¬(∃y . p(x, y ) ∧ p(x, z)) ∨ ∃y . p(x, y )
4. Result: ∀x∃y(¬P(x)∨Q(x))∨R(y)
Example2: ∃x∀y(P(x,y)∧Q(y))
1. Eliminate Implication: ∃x∀y(P(x,y)∧Q(y))
4. Result: ∃x∀y(P(x,y)∧Q(y))
Example3: ∀x∃y(P(x)∧Q(y))→∃zR(z)
1. Eliminate Implication: ¬∀x∃y(P(x)∧Q(y))∨∃zR(z)
4. Result: ∀y∃x∃z(¬(P(x)∧Q(y))∨R(z))
Example4: ∀x(P(x)∨∃yQ(x,y))→∃z∀wR(z,w)
1. Eliminate Implication: ¬∀x(P(x)∨∃yQ(x,y))∨∃z∀wR(z,w)
4. Result: ∃x∀y∃z∀w(¬P(x)∧¬Q(x,y)∨R(z,w))
Resolution in Predicate Logic
1. Anyone passing his/her AI exams and winning the lottery is happy.
∀X(pass(X, AI)) ⋀ win(X, lottery) → happy(X))
2. Anyone who studies or is lucky can pass all his/her exams.
∀X ∀Y(study(X) ∨ lucky(Y) → pass(X,Y))
3. Jyoti did not study but he/she is lucky.
¬ study(Jyoti) ⋀ lucky(Jyoti)
4. Anyone who is lucky wins the lottery.
∀X(lucky(X) →win(X,lottery)) ∨∧
Predicate into clausal form
1. ∀X(pass(X, AI)) ⋀ win(X, lottery) → happy(X))
1. ¬pass(X, AI)) ⋁ ¬ win(X, lottery) ⋁ happy(X)
2. ∀X ∀Y(study(X) ∨ lucky(X) → pass(X,Y))
2. ¬study(Y) ⋁ pass(Y,Z)
3. ¬lucky(W) ⋁ pass(W,V)
3. ¬ study(Jyoti) ⋀ lucky(Jyoti)
4. ¬ study(Jyoti)
5. lucky(Jyoti)
4. ∀X(lucky(X) →win(X,lottery))
6. ¬lucky(U) ⋁ win(U,lottery)
7. ¬happy(Jyoti)
Axioms in clause form
Prove that Jyoti is happy
1. ¬pass(X, AI)) ⋁ ¬ win(X, lottery) ⋁ happy(X)
2. ¬study(Y) ⋁ pass(Y,Z)
3. ¬lucky(W) ⋁ pass(W,V)
4. ¬ study(Jyoti)
5. lucky(Jyoti)
6. ¬lucky(U) ⋁ win(U,lottery)
7. ¬happy(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
{Jyoti/W,AI/V}
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
{Jyoti/W,AI/V}
¬lucky(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
{Jyoti/W,AI/V}
¬lucky(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
{Jyoti/W,AI/V}
¬lucky(Jyoti) lucky(Jyoti)
¬pass(X, AI) ⋁ ¬ win(X, lottery) ⋁ happy(X) ¬lucky(U) ⋁ win(U,lottery)
{U/X}
¬pass(U, AI) ⋁ happy(U) ⋁ ¬lucky(U) ¬happy(Jyoti)
{Jyoti/U}
{}
¬pass(Jyoti, AI) ¬lucky(W) ⋁ pass(W,V)
{Jyoti/W,AI/V}
¬lucky(Jyoti) lucky(Jyoti)
(2) (Ǝx)(Ǝy)Lxy Somebody loves somebody. (The somebody can be oneself or someone else.)
(3) (Ǝx)(Vy)Lxy There is one person who is such that he or she loves everyone. There is one person who loves
everyone. (There is one person who is such that, for all persons, the first loves the second, think of God as an example.)
(5) (Vx)(Ǝy)Lxy Every person is such that there is one person such that the first loves the second.
(each person has an object of their affection.)
(6) (Vx)(Ǝy)Lyx Everyone is loved by someone or other. No one goes unloved. (6) says something significantly weaker
than (3).
(7) (Ǝy)(Vx)Lyx
Referred From:
More examples on Multiple
Quantification:
{variable/function} if
variable does not occur
function FAIL
in function, FAIL
otherwise
Examples
P(x) unifies with P(A) using the substitution {x/A}
P(f(x), y, g(y)) unifies with P(f(w), z, g(A)) using the substitutions {x/w, y/z, z/A}
P(f(x), y, g(y)) fails to unify with P(f(w), B, g(A)) since y is unified with B and so it
cannot be unified with A
P(f(x), y, g(y)) fails to unify with P(f(w), f(A), g(A)) since y is unified with f(A) and so
it cannot be unified with A
knows(John, X) unifies with
Examples Unification
Predicates Substitutions (Theta)
love(x,y) and love(roop, jyoti) [roop/x, jyoti/y] or [jyoti/y,roop/x ] or [ ? ]
P(x,f(y)) and P(a,f(g(y))) [a/x,g(z)/y]
Q(a,g(x,a),f(y)) and Q(a, q(f(b),a),x) [f(b)/x,b/y]
R(h(x),a) and R(f(y),b) X
L(x, f(a)) and L(b,f(g(z)) [x/b,g(z)/a,a/z]
Cascaded Substitution
Two or more substitution is possible define a single substitution has same effect.
r{a,b,c} [{x|a},{f(e)|b},{z|c}] = r{x,f(e),z}
r{x,f(e),z} [ {u|e},{v|z}] = r{x,f(u),v}
r{a,b,c} [{x|a},{f(d)|b},{e|c}] = r{x,f(d),e}
Non-Uniqueness of Unification
Unifier 1:
p(x,y) [{a|x},{b|y},{b|v}] = p(a,b)
p(a,v) [{a|x},{b|y},{b|v}] = p(a,b)
Unifier 2:
p(x,y) [{a|x},{f(z)|y},{f(z)|b}] = p(a,f(z))
p(a,v) [{a|x},{f(z)|y},{f(z)|b}] = p(a,f(z))
Unifier 3:
p(x,y) [{a|x},{v|y}] = p(a,v)
p(a,v) [{a|x},{v|y}] = p(a,v)
Most General Unifier (MGU)
If two expressions are unifiable then they have an MGU that is unique upto
variable permutation.
Event Extraction
Hindi WordNet
Frames: Weak slot-and-filler representation
● Frames – semantic net with properties
● Can represent a specific entry, or a general concept.
● Represents an entity as a set of slots (attributes) and associated values.
● A node in a semantic network becomes an object in a set of frames, so an object
can define a class, a subclass or an instance of a class.
● Implicitly associated with another frame: the value of a slot can be another frame.
● Represent conceptual and commonsense knowledge.
Three components of a frame
- frame name
- attributes (slots)
- values (fillers: list of values, range, string, etc.)
Example using Predicates: Entity Jyoti
– Jyoti is an engineer as a profession, and his age is 45, he lives in city Jorhat,
and the country is India.
Use the Predicates IF ADDED → Jorhat
Slot Name Filler (Slot value)
Name Jyoti
Profession Engineer
Age 45
Weight 77
Salary IF NEEDED
City Jorhat
Features of Frame Representation
● More natural support of values than semantic nets
(each slots has constraints describing legal values that a slot can take)
● Can be easily implemented using object-oriented programming techniques
● Inheritance is easily controlled
Declarative Frame: root and leaf frame
Example: JEC (Administrator,Officeroom,Class room, Lab,Lib…)
Procedural Frame
- Actor Slot
- Object Slot
- Source Slot
- Destination Slot
- Task Slots
Advantages of Frame
● Makes programming easier by grouping related knowledge
● Easily understood by non-developers
● Expressive power
● Easy to set up slots for new properties and relations
● Easy to include default information and detect missing values
Drawbacks of Frame
● No standards (slot-filler values)
● More of a general methodology than a specific representation:
— Frame for a class-room will be different for a professor and for a
maintenance worker
● No associated reasoning/inference mechanisms
Concepts
भोजन उतना ही लें थाली में , क व्यथर्थ न जाये नाली में ।
थाली में उतना ही खाना लें, िजससे वह बेकार ना जाए ।
खाना खाओ मनभर ना छोडो कणभर ।
প্লেটত ইমানিখিন খাদ্যেহ লওক, যােত নলাত অপচয় নহয়।
थाली में एतना खाना ले लीं, ता क नाली में बेकार ना होखे।
প্লেেট শুধু এতটু কু খাবার িনন, যােত ড্রেেন নষ্ট না হয়।
Conceptual Dependency: Strong and Filler Structures
● defines a semantic base for natural language: different sentences have same
meaning have same unique CD representation.
● CD theory designed for everyday actions.
● CD is a set of actions (about world) that can be done by people.
● a model of NLU used in AI systems. Roger Schank at Stanford University
introduced the model in 1969.
● To help in the drawing of inference from sentences.
● Objective was to understand Natural Language stories.
● It has been used by many programs that portend to understand English
(MARGIE, SAM, PAM).
Application of CD
MARGIE
(Meaning Analysis, Response Generation and Inference on English) -- model
natural language understanding.
SAM
(Script Applier Mechanism) -- Scripts to understand stories.
PAM
(Plan Applier Mechanism) -- Scripts to understand stories.
Conceptual Dependency (Strong slot and filler structure)
Structured knowledge representation.
Kind of knowledge about events contained in NL Sentences
Conceptual Dependency
- conceptun at least a two-way dependency
- nominal are objects and people.
- actions are acts for nominals.
- modifier give addn info. on nominal/object
Sarah fixed the chair with glue.
ACT: stroke
s
tion
1) ATRANS: Transfer of an abstract relationship (give, accept, take)
ac
2) PTRANS: Transfer the physical location of an object ( Go, Come, Run, Walk)
own
3) MTRANS: Transfer the mental information (Tell)
nkn
for u
4) PROPEL: Application of physical force to an object (push, pull, throw)
5) MOVE: Movement of a body part by its owner (kick,punch).
used
6) GRASP: Grasping of an object by an action (clutch)
tion
y Ac
7) INGEST: Ingestion of an object by an animal (eat)
: An
8) EXPEL: Expulsion of anything from an animal body (cry)
9) MBUILD: Building new information out of old (decide)
Do
10) SPEAK: Production of sounds (say)
11) ATTEND: Focusing of a sense organ towards a stimulus (listen, watch )
Conventions
● Arrow indicate direction of dependency
● Double arrow indicates two way link between actor and action.
● All actions involve one or more of these
○ O for object case relation
○ R for recipient case relation
○ Directive case relation
○ Instrumental case relation
●
Conceptual tenses (Time of actions or state of being)
Representing Picture Aiders (PAs) or states
thing <≡> state-type (state-value)
The ball is red. ball <≡> color (red)
John is 6 feet tall. john <≡> height (6 feet)
John is tall. john <≡> height (>average)
John is taller than Jane. john <≡> height (X) jane <≡> height (Y) X > Y
John is angry. john <≡> anger(5)
John is furious. john <≡> anger(7)
John is irritated. john <≡> anger (2)
John is ill. john <≡> health (-3)
John is dead. john <≡> health (-10)
CD is a decompositional approach
Mary took a book from John.
A script is composed of
1) Entry Condition
2) Props (objects manipulated in the script)
3) Roles/actors (agents that can change the state of the world).
4) Tracks/ Events
5) Scene/Acts: A set of actions by the actors. (lamp post scene:Barfi)
6) Results
Entry Conditions: Conditions that must be satisfied for execution of the script. Whenever a script is referred, one can assume the
preconditions to be true. For example when we read a statement, Jay went to watch a cricket match, it is also
concluded that he has money to buy tickets and he is also a cricket fan. Even when not explicitly mentioned, entry
conditions can safely assumed to be true.
Results: The Conditions that will be true after exit. This is a general (and thus default) assumption. It might be false under
exceptional circumstances. For example when there is rain and the match is abandoned, watching does not happen.
Happy may also be false.
Props: Objects involved in the script. Tickets, seats etc. are other objects that the person deals with while watching a match.
Here also are some varieties, for example it is possible that with a pavilion ticket, he might also receive a food
coupon.
Roles: Persons involved in the script. Again, this is a general assumption. We have not mentioned fellow spectators, or
umpires or players in the simplified version of the script that we draw. If might involve all of them in the professionally
written scripts. A more detailed script might also involve events like tossing the coin between rival captains,
information about innings, score cards and so on.
Track: Specialization of the script derived from a general pattern. A general pattern may inherit multiple tracks. That means
multiple such tracks look quite similar but they have their own individually different scenes or other items associated.
For example watching a football match might contain referees, linemen, and so on while a detailed cricket match
might have a wicket keeper, umpires, a third umpire and so on.
Scenes: The sequence of events following a general default path. Events are represented in CD form but mentioned as a
semi-CD form, just describing the ACT and rest in English for pedagogy purpose.
Script for going to the bank to withdraw money.
SCRIPT : Withdraw money Scene 1: Entering Scene 2: Filling form
TRACK : Bank
P PTRANS P into the Bank P MTRANS signal to E
PROPS : Money E ATRANS form to P
P ATTEND eyes to E
Counter
P PTRANS P to E P PROPEL form for writing
Form
Token P ATRANS form to P
E ATRANS form to P
Roles : P= Customer E= Employee C= Cashier
Acts: Entry, Seating, Ordering a meal, Serving a meal, Eating the meal, requesting
the check, paying, leaving.
Beyond Classical Search: Adversarial
- In a normal/local search, follow a sequence of actions to reach the goal or to
finish the game optimally. (without strategy)
- Search in conflicting environment: one can trace the movement of an enemy
or opponent. (parties in a dispute)
- A situation where you are planning while another actor prepares against you.
- the players will decide the result of the game: compete or fight for win
- very prominent in Playing a Game
- Some games come under the luck of chance like dice games
- Some games two or more players play for the same goal.(teams)
GAME on AI: A reinforcement Learning
There are following types of adversarial search:
Minimax Algorithm: Pick the best next move against your best move
Alpha-beta Pruning:
Formal definition of game
game can a kind of search problem with the following elements:
S0 : The initial state, which specifies how the game is set up at the start.
PLAYER (s): Defines which player has the move in a state.
ACTIONS (s): Returns the set of legal moves in a state.
RESULT (s, a): The transition model, which defines the result of a move.
TERMINAL -TEST (s): A terminal test, which is true when the game is over and false
otherwise. States where the game has ended are called terminal states.
UTILITY (s, p): A utility function (also called an objective function or payoff function),
defines the final numeric value for a game that ends in terminal state s for a player p.
Chess: +1, 0, -1 , Poker: Cash won or lost
How to calculate the Utility/value/rank/goodness of NT nodes ?
Minimax Function
- Both Max and Min play optimally
- Whichever move Max takes, Min will choose the countermove that yields the
lowest utility score.
- Traverse the tree depth-first until the terminal nodes and assign their parent
node a value that is best for the player whose turn it is to move.
-
-
Working example of minimax procedure
- —-> Max’s move
A
—-> Min’s move.
MAX a1 a2 a3
- The game ends when a terminal (leaf) —----------------------------------------------------------
node is reached.
- The terminal value is the utility function’s
B C D
value written below the leaf node.
- if Max choose B, then Min would MIN b1 b2 b3 c1 c2 c3 d1 d2 d3
choose b3 because that’s the lowest —----------------------------------------------------------------------------------------------------
possible value.
E F G H I J K L M
- if Max choose C, then Min would 31 20 12 2 8 16 12 1 5
choose __?
B = MIN(E,F,G) = MIN (31,20,12) = 12
C = MIN(H,I,J) = MIN (2,8,16) = 2
A = MAX(B,C,D)
= MAX (MIN(E,F,G), MIN(H,I,J), MIN(K,L,M)) All Non-terminal nodes are Calculated.
= MAX(12,2,1) = 12
Game Tree for Tic-tac-toe (noughts and crosses)
Beta: Beta is the best choice or the lowest value that we have found at any instance along the path of
Minimizer. The initial value for alpha is + ∞.
Each node has to keep track of its alpha and beta values. Alpha can be updated only when it’s MAX’s turn
and, similarly, beta can be updated only when it’s MIN’s chance.
MAX player will update only alpha values and MIN player will update only beta values.
The node values will be passed to upper nodes instead of values of alpha and beta during go into reverse
of tree.
Three cases:
Worst case (Time Complexity is similar to the minimax algorithm) BAD
Best case: Best case means perfect move where lots of pruning could exist.
Average case: Is the point of discussion here.
Analysis
Alpha-Beta Analysis
Analysis wiki
Saving
Even Depth
O(b×1×b×1×...×1) for even depth
all the first player's moves must be studied to find the best one, but for each, only
the second player's best move is needed to refute all but the first (and best) first
player move—alpha–beta ensures no other second player moves need be
considered.
Where the ply of a search is even, the effective branching factor is reduced to its
square root, or, equivalently, the search can go twice as deep with the same
amount of computation.
It is O(b^(d/2)) with small values of b and d doesn't really make sense.
explanation of b*1*b*1*...
All the first player's moves must be studied to find the best one, but for each, only
the best second player's move is needed to refute all but the first (and best) first
player move – alpha–beta ensures no other second player moves need be
considered.
MAX
MIN
MAX
MIN
A B C D E F
Two Strategies: S1 and S2
A B C D A B C D
Strategy s3 Strategy s4
A B C D A B C D
S2: {50,40, B, C}
S4: {30,A, B, C}
Value of a Strategy
The agent takes action on degree of belief that will be probability theory (0 ≤ p ≤1)
Sources of Uncertainty in AI
- Data Uncertainty: Noisy or incomplete data can affect quality and accuracy
- Model Uncertainty: model architecture, optimization algorithm, and
hyperparameters can significantly impact the performance.
- Algorithmic Uncertainty: different ML algorithms can produce different predictions
for the same dataset.
- Environmental Uncertainty: autonomous vehicle may encounter unexpected
weather conditions or road construction
- Human Uncertainty: Human behavior and preferences part of the decision-making
process and adoption of AI systems.
Image Segmentation
Uncertainty in image processing : uncertainty of which class or category a pixel or
region belongs to.
Techniques for Addressing Uncertainty
01- programming paradigm combines logic programming with probabilities.
It is based on the distribution semantics. Word Embedding an NLP application.
Probabilistics reasoning
- 0 ≤ P(A) ≤ 1
0 → uncertainty
1 → certainty
- Event: each possible outcome of a variable
Sample space: all possible events
Random variable: represents events and object
Prior probability:
Posterior probability:
Conditional probability
- Thomas Bayes rule
Machine Translation (paper)
several semantically equivalent translations of the same source sentence
Semantic similarity is the similarity between two words or two sentences/phrase/text.
Fuzzy Logic
- Boolean Logic (two possibility) {0,1}
- Real time?
- Frizzy meaning ?
- Confront circumstances where we can't decide if something is valid or bogus.
- Lotfi Zadeh conceptualized fuzzy logic in 1965
- Examples “Is it hot water? Am I tall ? I have eaten Pizza”
- Diversity of values
- A technique for computational “thinking” that resembles human thinking.
Membership Function
- Represent in degrees
- Represent belongingness of a member of a crisp set to Fuzzy set
Fuzzy set, Ã = {(x1, 0.6), (x2, 0.2), (x3, 1), (x4, 0.4)}
Fuzzy set, B̃ = {(x1, 0.1), (x2, 0.8), (x3, 0), (x4, 0.3)}
𝝁ÃUB ̃ (x) = {(x1, 0.6), (x2, 0.8), (x3, 1), (x4, 0.4)}
= {(0.6/x1), (0.8/x2), (1/x2), (0.4/x4)}
﹣₋
Intersection on Fuzzy set
Fuzzy set, Ã = {(x1, 0.6), (x2, 0.2), (x3, 1), (x4, 0.4)}
Fuzzy set, B̃ = {(x1, 0.1), (x2, 0.8), (x3, 0), (x4, 0.3)}
𝝁Ã∩B ̃ (x) = {(x1, 0.1), (x2, 0.2), (x3, 0), (x4, 0.3)}
Complement on Fuzzy set
μĀ(x) = 1-μĀ(x)
Ã(X) X B̃ (Y) = y1 y2 y3 y4
x1 0.2 0.6 0.6 0.6
x2 0.2 0.5 0.5 0.5
x3 0.2 0.4 0.4 0.4
x4 0.2 0.2 0.2 0.2
Prolog
Logic vs functional programming
PROgramming in LOGic
● 4GL supports the declarative programming paradigm.
● suitable for symbolic or non-numeric computation.
● Prolog always performs depth-first-search, Matches facts & rules (i.e.
knowledge base) in top-down manner.
● Prolog resolves the goals or subgoals in left-to-right manner.
● Prolog query will return 'true' (success) only if all of the subgoals are satisfied.
● References:
■ Logic Programming:
■ Booklm
■ AIPP-PDF-SLIDES
■ Books
●
The central ideas of Prolog
● SUCCESS/FAILURE
– any computation can “succeed'' or “fail'', and this is used as a ‘test‘ mechanism.
● MATCHING
– any two data items can be compared for similarity, and values can be bound to
variables in order to allow a match to succeed.
● SEARCHING
– the whole activity of the Prolog system is to search through various options to find
a combination that succeeds.
• Main search tools are backtracking and recursion
● BACKTRACKING
– when the system fails during its search, it returns to previous choices to see if
making a different choice would allow success.
Prolog Terminologies
Predicate Arguments
● A body can be made up of any number of subgoals (calls to other
predicates) and terms.
● Arguments also consist of terms, which can be:
■ Constants e.g. jyoti,
■ Variables e.g. Person1, or X
■ Compound terms
Terms: Constants
Constants can either be:
● Numbers:
■ integers are the usual form (e.g. 1, 0, -1, etc)
■ floating-point numbers can also be used (e.g. 3.0E7)
● Symbolic (non-numeric) constants:
■ always start with a lower case alphabetic character and contain any mixture of letters,
digits, and underscores (but no spaces, punctuation, or an initial capital).
■ e.g. abc, big_long_constant, x4_3t).
● String constants:
■ anything between single quotes e.g. ‘Like this’.
Terms: Variables
● Variables always start with an upper case alphabetic character or an
underscore.
● Other than the first character they can be made up of any mixture of letters,
digits, and underscores. e.g. X, ABC, _89two5, _very_long_variable
● There are no “types” for variables (or constants) – a variable can take any
value.
● All Prolog variables have a “local” scope:
– they only keep the same value within a clause; the same variable used
outside of a clause does not inherit the value (this would be a “global” scope).
Naming Tips
● Use real English when naming predicates, constants, and variables.
e.g. “John wants to help Somebody.”
Could be: wants(john,to_help,Somebody).
Not: x87g(j,_789).
● name of arguments may contain(-) hyphen but not double hyphen (--)
e.g. teaches(george-F-Colony, dataAnalytics).
But not teaches(george–F-Colony, dataAnalytics).
Prolog Syntax: Symbols
Prolog expressions are comprised by truth-functional symbols:
| ?- trace.
The debugger will first creep -- showing everything (trace)
yes
{trace}
| ?-
| ?- notrace.
The debugger is switched off
yes
| ?-
Compound Terms
● representation of data with substructure
● consists of a functor followed by a sequence of one or more
subterms called arguments.
For example, the term
sentence(nphrase(suriya),vbphrase(verb(likes),nphrase(jyothika)))
could be depicted as the structure:
______sentence______
| |
nphrase _____vbphrase_____
| | |
suriya verb nphrase
| |
likes jyothika
sentence is the principal functor
arguments are nphrase(suriya) and vbphrase(verb(likes),nphrase(jyothika)).
Compound Terms
predicate functor(Term, F, A),
succeeds if Term has functor F and arity A. Its behaviour is as follows:
| ?- functor(sentence(nphrase(suriya),vbphrase(verb(likes),nphrase(jyothika))),Functor,
Arity).
Arity = 2
Functor = sentence
yes
| ?-
● Conjunction in Goal :
?- place(sunny), place(windy).
// Is place sunny and windy? OR Is place sunny? and Is place windy?
Example of Disjunction: semicolon ';' read as 'or'.
disjunction_goal.pl
greet(jyoti):-
write('How are you doin, roop?'), nl.
greet(roop):-
write('Awfully nice to see you!').