Knowledge Representation in AI
Knowledge representation plays a crucial role in artificial Intelligence. It has to do with the ‘thinking’ of AI systems and contributes to its intelligent behavior. Knowledge Representation is a radical and new approach in AI that is changing the world. is concerned with presenting real-world information in a form that the computer can ‘understand’ and use to ‘solve’ real - life problem or ‘handle’ real-life task. The ability of machines to think and act like humans such as understanding, interpreting and reasoning constitute knowledge representation. It is related to designing agents that can think and ensure that such thinking can constructively contribute to the agent’s behavior.
In simple words, knowledge representation allows machines to behave like humans by empowering an AI machine to learn from available information, experience or experts.
My self Happy khatun. I am a student of city university. And this blog is a part of our AI (Artificial Intilegent) Lab Course conducted by our most honorable teacher Nuruzzaman Faruqui.
In this blog, we will develop a game engine that will detect a murder based on its knowledge base.
Here is a problem which we will solve. Suppose there is a dead body of a Doctor called Doctor Black .It has been found Yesterday. There were only three people in Doctor Black’s mansion. Now we have to detect the murderer using AI. We have the following information in our hand regarding to start our investigation.
Three prime suspects:
Col. Mustard
Prof. Plum
Ms. Scarlet
Three weapons (Founded by the police in the mansion)
Knife
Revolver
Wrench
There is three rooms in his mansion
Ballroom
Kitchen
Library
Now we will find find the murderer based on this above information. For this we have implement the following code:
# we import termcolor to change the colour in terminal window
import termcolor
# we have import the logic file
from logic import *
#Now we are symboling all of the charecters,rooms,weapons
mustard=Symbol("col.mustard")
plum=Symbol("ProfPlum")
scarlet=Symbol("MsScarlet")
charecters=[mustard,plum,scarlet]
ballroom=Symbol("ballroom")
kitchen=Symbol("kitchen")
library=Symbol("library")
rooms=[ballroom,kitchen,library]
revolber=Symbol("revolber")
knife=Symbol("knife")
wrench=Symbol("wrench")
wreapons=[revolber,knife,wrench]
# Now we are concating characters , rooms and weapons in symbols.
symbols=charecters+rooms+wreapons
# we are checking the model and get some truth value
def check_knowledge(knowledge_base):
for symbol in symbols:
if model_check(knowledge_base,symbol):
termcolor.cprint(f"{symbol}:YES","green")
elif not model_check(knowledge_base,Not(symbol)):
print(f"{symbol}:Maybe")
# Createing knowledge base
knowledge_base=And(
Or(mustard,plum,scarlet),
Or(ballroom,kitchen,library),
Or(knife,revolber,wrench)
)
# They are clue
knowledge_base.add(And(
Not(mustard),Not(kitchen),Not(wrench)
))
knowledge_base.add(Or(
Not(scarlet),Not(library),Not(wrench)
))
knowledge_base.add(Not(plum))
knowledge_base.add(Not(ballroom))
knowledge_base.add(Not(revolber))
check_knowledge(knowledge_base)
After running this code we get the following result:
In artificial intelligence, knowledge can be represented in various ways depending on the structure of the knowledge or the perspective of the designer or even the type of internal structure used. An effective knowledge representation should be rich enough to include the knowledge required to solve the problem. It should be natural, compact and maintainable. it is important to choose the right type of knowledge representation .Knowledge and logical reasoning play a huge role in artificial intelligence. However, you often require more than just general and powerful methods to ensure intelligent behavior. And this blog is the easiest solution to prepare oneself in order to learn knowledge representation through AI.



No comments:
Post a Comment