Constraint Specification and Knowledge Base Que-1: Explain Crypto Arithmetic Problem: (CSP: Constraint Satisfaction Problem)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Chapter 3

Constraint Specification and Knowledge Base

Que-1: Explain Crypto Arithmetic Problem: (CSP: Constraint satisfaction


problem)

Crypt-arithmetic problem is where numbers are replaced by alphabets. Using arithmetic rules,
we need to get the numbers from the alphabet.
Example

S E N D
+ M O R E
M O N E Y

General Rules:
1. Each alphabet takes only one number from 0 to 9 uniquely. (A=1, B=5…)
2. Sum of two single digit numbers can be maximum 19 with carry and 18 without carry.
3. Maximum value of Carry in two number addition is always 1.
4. Try to solve leftmost digit in the given problem

Example:
if (a x b) = kb then finds out various possible solution of a, b and k.

solution:
1. (3 x 5) = 15 k=1, a=3, b=5
2. (7 x 5) = 35 k=3, a=7, b=5
3. (6 x 8) = 48 k=4, a=6, b=8
4. (6 x 4) = 24 k=2, a=6, b=4
5. (9 x 5) = 45 k=4, a=9, b=5
6. (6 x 2) = 12 k=1, a=6, b=2

Que 2: Explain Constraints in Crypt-arithmetic Problems


1. No two digits can be assigned the same letter.
2. Only the single digit number can be assigned to a letter.
3. Any search techniques can be used.
4. Backtracking can be applied.
5. Rules of arithmetic must be followed.
Que 3: The following question are based on the multiplication given below.

First number J E
Second number X B B
J E
J E A
B A D E

1. Find the value of J and A


2. If E = 4, What is the value of D ?

First number 1 2
Second number X 2 3
3 6
2 4 0
0 2 7 6
(Above table shows multiplication of 12 and 23)

By comparing to above problem, we found that A=0


JE X B = JE  means B = 1

First number J E
Second number X 1 1
J E
J E 0
1 0 D E

E=4, which is given

First number J 4
Second number X 1 1
J 4
J 4 0
1 0 D 4

1 + J = 10 J = 10 -1 = 9

First number 9 4
Second number X 1 1
9 4
9 4 0
1 0 3 4

9 + 4 = 1D1D=13D=3
Que 4: If SEND + MORE = MONEY, then find the respective values of alphabets.

S E N D
+ M O R E
M O N E Y

S E N D
+ 1 O R E
1 O N E Y

S=9 or S=8 with carry over (S + 1=10, S=9 / 1 + S + 1 = 10, S=10-2=8)


Assume S=9, means O=0

9 E N D
+ 1 0 R E
1 0 N E Y

E + 0 = N E = N which is not possible


1 + E + 0 = N  which is possible E = (N -1)
N + R = 10 + E =1E
N + R = 10 + N -1
R = 10 -1 = 9which is not possible because 9 is assigned to S
1 + N + R = 10 + E
1 + N + R = 10 + N – 1
R = 9 – 1 =8  which is possible

9 E N D
+ 1 0 8 E
1 0 N E Y

(N, E) can be (7,6) or (6,5)


Assume N=6, E=5

9 5 6 D
+ 1 0 8 5
1 0 6 5 Y
Assume D=7 so we obtained Y =2
9 5 6 7
+ 1 0 8 5
1 0 6 5 2

Que 5: From the table given below find the value of NAME.
First number H E
Second number X E H
H E
H H A
H N M E

HE x H = HE means H=1

First number 1 E
Second number X E 1
1 E
1 1 A
1 N M E

(1 + A) = M- generates carry means A=9


(1 + 9) = 10 means M=0 and N=1 + 1 = 2

First number 1 E
Second number X E 1
1 E
1 1 9
1 2 0 E

1E x E =119  by trial and error we found that 17 x 7 = 119 means E=7

First number 1 7
Second number X 7 1
1 7
1 1 9
1 2 0 7

So NAME = 2907
Que 6:
(a) If GO + TO = OUT, then O + U + T = ?
(b) If USA + USSR = PEACE. Find P + E + A + C + E.
(a)

G O
+ T O
O U T

Clearly you can say that O=1 because carry is generated and it is always 1.

G 1
+ T 1
1 U T

1 + 1 = T means T=2

G 1
+ 2 1
1 U 2

If G=9 then 9 + 2 = 11 means U=1 which is not possible because O=1


If G=8 then 8 + 2 = 10 means U=0 which is possible

8 1
+ 2 1
1 0 2

Answer: O + U + T = 1 + 0 + 2 = 3
(b) If USA + USSR = PEACE. Find P + E + A + C + E.

- U S A
+ U S S R
P E A C E

Addition of 3 digit number and 4 digit number is 5 digit number means fifth digit is carry
which is always 1. Means P = 1.

- U S A
+ U S S R
1 E A C E
U = E which is not possible
1 + U = 10 + E is possible from this we can say that U = 9 and E = 0

- 9 S A
+ 9 S S R
1 0 A C 0
A + R = E = 0 with carry 1.
so, A = 2 and R = 8
U + S = A = 2 with carry 1, S = 3
S + S + 1 = C, 3 + 3 + 1 = c = 7
932 + 9338 = 10270
so,P + E + A + C + E = 1 + 0 + 2 + 7 + 0 = 10

Que 7: Explain map Colouring problem in AI.(CSP : Constraint satisfaction


Problem)
 In Map colouring problem use needs to colour various parts of the map.
 Constraint is that no two neighbouring / adjacent states or blocks have same colour.

 Assume above figure is the map of country where there are 5 states.
 We have to fill the colour in such a way that no two adjacent states / borders contain
same colour.
 Draw the constraint graph for above map first to solve the problem.

1 2

4
5
 Above figure is constraint graph of above map.
 Nodes represent different states while edges represent boundary between two
states.
 Constraints are of three types
o Unary constraint: It is having one variable only.
o Binary Constraint: It is having two variables only.
o Higher order Constraint: it is having multiple variables.
 CSP are the problem which involves backtracking. It is an optimization of BFS and
DFS.
 Various processes involved in solving CSP are
o filtering,
o ordering,
o structuring etc.
o below figure shows one of the possible solution of colour mapping
problem

Que 8: Explain Propositional Logic and 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 are all propositions because they have a specific truth value, true
or false.
1. (a+b)2 = a2 + 2ab + b2
2. If x is real, then x2 >= 0
3. If x is real, then x2 < 0
4. The sun rises in the east.
5. The sun rises in the west.
The branch of logic that deals with proposition is propositional 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.
The set of values that the variables of the predicate can assume is called the Universe or
Domain of Discourse or Domain of Predicate.

Que 9: Give the Difference between Propositional Logic and Predicate Logic.

Propositional Logic Predicate Logic

Predicate logic is an expression consisting


Propositional logic is the logic that
of variables in specific domain. It consists
1 deals with a collection of statements
of objects, relations and functions
which have a truth value, true or false.
between the objects.

It is the basic and most widely used


2 It is an extension of propositional logic
logic. Also known as Boolean logic.

A proposition has a specific truth A predicate’s truth value depends on the


3
value, either true or false. variables’ value.

Scope analysis is not done in Predicate logic helps analyze the scope of
4
propositional logic. the subject over the predicate.
Propositions are combined with Logical Predicate Logic adds by introducing
5
Operators quantifiers

6 It is a more generalized representation. It is a more specialized representation.

7 It cannot deal with sets of entities. It deal with set of entities

Que 10: What is refutation? What is resolution? What is unification?


 The act of saying or proving that a person, statement, opinion, etc. is wrong or false is
called refutation.
 Resolution is a theorem proving technique that proceeds by building refutation
proofs, i.e., proofs by contradictions. It was invented by a Mathematician John Alan
Robinson in the year 1965.
 Unification is a key concept in proofs by resolutions.

Que 11: Explain Monotonic reasoning and Non-monotonic reasoning.

Monotonic Reasoning

Monotonic Reasoning is the process that does not change its direction or can say that it moves
in the one direction.
 Monotonic Reasoning will move in the same direction continuously means it will either
move in increasing order or decrease.
 But since Monotonic Reasoning depends on knowledge and facts, It will only increase and
will never decrease in this reasoning.
 Example:
 Sun rises in the East and sets in the West.

Non-monotonic Reasoning
Non-monotonic Reasoning is the process that changes its direction or values as the knowledge
base increases.
 It is also known as NMR in Artificial Intelligence.
 Non-monotonic Reasoning will increase or decrease based on the condition.
 Since that Non-monotonic Reasoning depends on assumptions, It will change itself with
improving knowledge or facts.
 Example:
 Consider a bowl of water, If we put it on the stove and turn the flame on it
will obviously boil hot and as we will turn off the flame it will cool down
gradually.
Que 12: Give the differences between Monotonic Reasoning and Non-
Monotonic Reasoning.

Monotonic Reasoning Non-Monotonic Reasoning

Monotonic Reasoning is the process


Non-monotonic Reasoning is the process
which does not change its direction or
which changes its direction or values as the
can say that it moves in the one
knowledge base increases.
1 direction.

Monotonic Reasoning deals with very Non-monotonic reasoning deals with


2 specific type of models. incomplete or not known facts.

The addition in knowledge won’t The addition in knowledge will change the
3 change the result. result.

In non-monotonic reasoning, results and


In monotonic reasoning, results are
set of prepositions will increase and
always true, therefore, set of
decrease based on condition of added
prepositions will only increase.
4 knowledge.

Monotonic Reasoning is based on true Non-monotonic Reasoning is based on


5 facts. assumptions.

Deductive Reasoning is the type of Human Reasoning is a non-monotonic type


6 monotonic reasoning. of reasoning.

Que 13: Explain Probabilistic reasoning and concept of probability.


Probabilistic reasoning:
Probabilistic reasoning is a way of knowledge representation where we apply the concept of
probability to indicate the uncertainty in knowledge. In probabilistic reasoning, we combine
probability theory with logic to handle the uncertainty.

Need of probabilistic reasoning in AI:

o When there are unpredictable outcomes.


o When specifications or possibilities of predicates becomes too large to handle.
o When an unknown error occurs during an experiment.
In probabilistic reasoning, there are two ways to solve problems with uncertain knowledge:

 Bayes' rule
 Bayesian Statistics

As probabilistic reasoning uses probability and related terms, so before understanding


probabilistic reasoning, let's understand some common terms:

Probability:

Probability can be defined as a chance that an uncertain event will occur. It is the numerical
measure of the likelihood that an event will occur. The value of probability always remains
between 0 and 1 that represent ideal uncertainties.

1. 0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.

1. P(A) = 0, indicates total uncertainty in an event A.

1. P(A) =1, indicates total certainty in an event A.

We can find the probability of an uncertain event by using the below formula.

o P(A’) = probability of a not happening event.


o P(A’) + P(A) = 1.

Event: Each possible outcome of a variable is called an event.

Sample space: The collection of all possible events is called sample space.
Conditional probability:
Conditional probability is a probability of occurring an event when another event has already
happened.

Let's suppose, we want to calculate the event A when event B has already occurred, "the
probability of A under the conditions of B", it can be written as:

Where P(A⋀B)= Joint probability of a and B


P(B)= Marginal probability of B.

If the probability of A is given and we need to find the probability of B, then it will be given
as:

It can be explained by using the below Venn diagram, where B is occurred event, so sample
space will be reduced to set B, and now we can only calculate event A when event B is already
occurred by dividing the probability of P(A⋀B) by P( B ).

Que 14: In a class, there are 70% of the students who like English and 40% of
the students who likes English and mathematics, and then what is the percent
of students those who like English also like mathematics?

Solution:

Let, A is an event that a student likes Mathematics

B is an event that a student likes English.

Hence, 57% are the students who like English also like Mathematics.

Que 15: Explain Bayes' theorem in Artificial intelligence


Bayes' theorem:

Bayes' theorem is also known as Bayes' rule, Bayes' law, or Bayesian reasoning, which
determines the probability of an event with uncertain knowledge.

In probability theory, it relates the conditional probability and marginal probabilities of two
random events.

Bayes' theorem was named after the British mathematician Thomas Bayes. The Bayesian
inference is an application of Bayes' theorem, which is fundamental to Bayesian statistics.
It is a way to calculate the value of P(B|A) with the knowledge of P(A|B).

Bayes' theorem allows updating the probability prediction of an event by observing new
information of the real world.

Example: If cancer corresponds to one's age then by using Bayes' theorem, we can determine
the probability of cancer more accurately with the help of age.

Bayes' theorem can be derived using product rule and conditional probability of event A with
known event B:

As from product rule we can write:

1. P(A ⋀ B)= P(A|B) P(B)

Similarly, the probability of event B with known event A:

1. P(A ⋀ B)= P(B|A) P(A)

Equating right hand side of both the equations, we will get:

The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic of
most modern AI systems for probabilistic inference.

It shows the simple relationship between joint and conditional probabilities.

Que 16: From a standard deck of playing cards, a single card is drawn. The
probability that the card is king is 4/52, then calculate posterior probability
P(King|Face), which means the drawn face card is a king card.

Solution:

P(king): probability that the card is King= 4/52= 1/13

P(face): probability that a card is a face card= 3/13

P(Face|King): probability of face card when we assume it is a king = 1

Putting all values in equation (i) we will get:


Que 17: Question: what is the probability that a patient has diseases
meningitis with a stiff neck?

Given Data:

A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it occurs
80% of the time. He is also aware of some more facts, which are given as follows:

o The Known probability that a patient has meningitis disease is 1/30,000.


o The Known probability that a patient has a stiff neck is 2%.

Let a be the proposition that patient has stiff neck and b be the proposition that patient has
meningitis. , so we can calculate the following as:

P(a|b) = 0.8

P(b) = 1/30000

P(a)= .02

Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff
neck.

You might also like