0% found this document useful (0 votes)
86 views50 pages

Unit 1 AI

Uploaded by

Mihir Maisuria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views50 pages

Unit 1 AI

Uploaded by

Mihir Maisuria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Introduction to AI

Prepared by: Prof. Foram Shukla


Outline
❏ Defining Artificial Intelligence
❏ Defining AI techniques
❏ Using Predicate Logic and Representing Knowledge as Rules
❏ Representing simple facts in logic
❏ Computable functions and predicates
❏ Procedural vs Declarative knowledge
❏ Logic Programming
❏ Mathematical foundations: Matrix Theory and Statistics for Machine Learning.
Artificial Intelligence (AI)
Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think
and learn like humans.
The goal of AI is to develop systems that can perform tasks that typically require human intelligence, such as
problem-solving, understanding natural language, speech recognition, visual perception, and decision-making.

AI programming focuses on cognitive skills that include the following:

● Learning. This aspect of AI programming focuses on acquiring data and creating rules for how to turn it
into actionable information. The rules, which are called algorithms, provide computing devices with
step-by-step instructions for how to complete a specific task.
● Reasoning. This aspect of AI programming focuses on choosing the right algorithm to reach a desired
outcome.
● Self-correction. This aspect of AI programming is designed to continually fine-tune algorithms and ensure
they provide the most accurate results possible.
● Creativity. This aspect of AI uses neural networks, rules-based systems, statistical methods and other AI
techniques to generate new images, new text, new music and new ideas.
Strong AI vs. weak AI
AI can be categorized as weak or strong.

● Weak AI, also known as narrow AI, is designed and trained to complete a specific task.

Industrial robots and virtual personal assistants, such as Apple's Siri, use weak AI.

● Strong AI, also known as artificial general intelligence (AGI), describes programming that

can replicate the cognitive abilities of the human brain. When presented with an unfamiliar

task, a strong AI system can use fuzzy logic to apply knowledge from one domain to

another and find a solution autonomously. In theory, a strong AI program should be able

to pass both a Turing test and the Chinese Room argument.


AI techniques
AI technique is a method that exploits knowledge that should There are three important AI techniques:
be represented in such a way that:
1. Search — Provides a way of solving problems for
● Knowledge captures generalisation. Situations that
which no direct approach is available. It also provides
share common properties are grouped together.
a framework into which any direct techniques that are
Without the property, inordinate amount of memory
available can be embedded.
and modifications will be required.
2. Use of knowledge — Provides a way of solving
● It can be easily modified to correct errors and to reflect
complex problems by exploiting the structure of the
changes in the world.
objects that are involved.
● It can be used in many situations even though it may
3. Abstraction — Provides a way of separating
not be totally accurate or complete.
important features and variations from many
● It can be used to reduce its own volume by narrowing
unimportant ones that would otherwise overwhelm
range of possibilities.
any process.
Using Predicate logic
•One of the core problems in developing an intelligent system is “Knowledge
Representation” i.e. solving the problems of
(1)How to represent the knowledge one has about a problem domain and
(2)How to reason using that knowledge in order to answer questions
question or make decisions
•Logic is one of the oldest representation language studied for AI & is the
foundation for many existing systems that uses logic as either inspiration or the
basis for the tools in that system
(for Eg: rule based expert system &the prolog programming language
•The objective of a Knowledge representation is to express
knowledge in computer-manipulatable form such that it can be
used to help agents perform well.
•Thus for a knowledge-based intelligent agent, we need:
1. To represent knowledge about the world in formal language
2. To reason about the world using interferences in the language
3. To decide what action to take by interfering that the selected
action is good.
•Following are the aspects of knowledge representation Language:
Syntax: It is used to define the legal sentences in the language in which each sentence is
implemented by a physical organization of some part of the agent.
Eg: if x & y are numeric expressions then x>=y is a legal sentence.
Semantics: It is used to determine the facts in the world to which the sentences refer. Without
semantics syntax is just a meaningless arrangement of symbols so it plays important role
Eg: The semantics of the language tells us when sentences like a>=b are true & when
they are false.
LOGIC: Languages with specifically defined syntax & semantics are called Logics.
In this case , we can develop an inference mechanism for an agent that uses the
language and a sentence inside of a computer which is not a fact but it is a representation
of a fact.
An inference mechanism must ensure that it allows the new sentences to be derived
from existing ones only when the new fact is true just when the existing ones are.
First-Order logic:
○ First-order logic is another way of
Basic Elements of First-order logic:

knowledge representation in artificial


intelligence. It is an extension to
propositional logic.
○ FOL is sufficiently expressive to represent
the natural language statements in a
concise way.
○ First-order logic is also known as
Predicate logic or First-order predicate
logic. First-order logic is a powerful
language that develops information about
the objects in a more easy way and can
also express the relationship between
Complex Sentences:
Atomic sentences:
○ Complex sentences are made by combining

○ Atomic sentences are the most basic atomic sentences using connectives.

sentences of first-order logic. These First-order logic statements can be divided into two
parts:
sentences are formed from a predicate
○ Subject: Subject is the main part of the
symbol followed by a parenthesis with
statement.
a sequence of terms. ○ Predicate: A predicate can be defined as a
○ We can represent atomic sentences as relation, which binds two atoms together in a
statement.
Predicate (term1, term2, ......, term n).
Consider the statement: "x is an integer.", it consists
Example: Ravi and Ajay are brothers: => of two parts, the first part x is the subject of the
statement and second part "is an integer," is known
Brothers(Ravi, Ajay). as a predicate.
Chinky is a cat: => cat (Chinky).
Quantifiers in First-order logic:
○ A quantifier is a language element which generates quantification, and quantification specifies the quantity of
specimen in the universe of discourse.
○ These are the symbols that permit to determine or identify the range and scope of the variable in the logical
expression. There are two types of quantifier:
a. Universal Quantifier, (for all, everyone, everything)
b. Existential quantifier, (for some, at least one).

Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the statement within its range is true for
everything or every instance of a particular thing.

The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.

Note: In universal quantifier we use implication "→".

If x is a variable, then ∀x is read as:

○ For all x
○ For each x
○ For every x.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true for at least one
instance of something.

It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a predicate variable then it is
called as an existential quantifier.

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).

If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:

○ There exists a 'x.'


○ For some 'x.'
○ For at least one 'x.'
Representation Simple Facts in Logic
•Propositional logic is the branch of logic concerned with the study of
propositions (whether they are true or false) that are formed by other
propositions with the use of logical connectives, and how their value
depends on the truth value of their components.
•Characteristics of Proportional Logic:
1.It is Declarative
2.Allows partial / negated interference
3.It is compositional (two sentences can be joined)
4. Meaning is context independent
○ Propositional logic is also called Boolean logic as it works on 0 and 1.
○ In propositional logic, we use symbolic variables to represent the logic, and we can use any
symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
○ Propositions can be either true or false, but it cannot be both.
○ Propositional logic consists of an object, relations or function, and logical connectives.
○ These connectives are also called logical operators.
○ The propositions and connectives are the basic elements of the propositional logic.
○ Connectives can be said as a logical operator which connects two sentences.
○ A proposition formula which is always true is called tautology, and it is also called a valid
sentence.
○ A proposition formula which is always false is called Contradiction.
○ A proposition formula which has both true and false values is called
○ Statements which are questions, commands, or opinions are not propositions such as
"Where is Rohini", "How are you", "What is your name", are not propositions.
Logical Connectives:
Logical connectives are used to connect two simpler propositions or representing a sentence logically. We can create
compound propositions with the help of logical connectives. There are mainly five connectives, which are given as follows:

1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive literal or negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and Q are the
propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
4. Implication: A sentence such as P → Q, is called an implication. Implications are also known as if-then rules. It can
be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Procedural knowledge
Examples of procedural language
Declarative knowledge
Examples of declarative knowledge
Difference between procedural & declarative knowledge
Logic programming
● Prolog is a logic programming language. It has important role in artificial intelligence.
● Unlike many other programming languages, Prolog is intended primarily as a declarative programming
language.
● In prolog, logic is expressed as relations (called as Facts and Rules).
● In prolog, We declare some facts. These facts constitute the Knowledge Base of the system. We can query
against the Knowledge Base.
● We get output as affirmative if our query is already in the knowledge Base or it is implied by Knowledge
Base, otherwise we get output as negative.
● So, Knowledge Base can be considered similar to database, against which we can query. Prolog facts are
expressed in definite pattern. Facts contain entities and their relation. Entities are written within the
parenthesis separated by comma (, ). Their relation is expressed at the start and outside the parenthesis.
● Every fact/rule ends with a dot (.). So, a typical prolog fact goes as follows :
Advantages :

1. Easy to build database. Doesn’t need a lot of programming effort.


2. Pattern matching is easy. Search is recursion based.
3. It has built in list handling. Makes it easier to play with any algorithm involving lists.
Disadvantages :

1. LISP (another logic programming language) dominates over prolog with respect to I/O features.
2. Sometimes input and output is not easy.
Applications :
Prolog is highly used in artificial intelligence(AI). Prolog is also used for pattern matching over
natural language parse trees.
Mathematical foundations: Matrix Theory and Statistics for Machine Learning.

Matrix Theory:

● Matrices are a foundational element of linear algebra.


● Matrices are used throughout the field of machine learning in the description of algorithms and processes such
as the input data variable (X) when training an algorithm.
● A matrix is a two-dimensional array of scalars with one or more columns and one or more rows.
● We can represent a matrix in Python using a two-dimensional NumPy array.
● A NumPy array can be constructed given a list of lists. For example, below is a 2 row, 3 column
matrix.
Matrix addition
Matrix subtraction
example
Matrix Multiplication
Statistics
● Statistics is a core component of data analytics and machine learning.
● It helps you analyze and visualize data to find unseen patterns.
● Statistics is a branch of mathematics that deals with collecting, analyzing, interpreting, and visualizing
empirical data. Descriptive statistics and inferential statistics are the two major areas of statistics.
● Descriptive statistics are for describing the properties of sample and population data (what has
happened).
● Inferential statistics use those properties to test hypotheses, reach conclusions, and make predictions
(what can you expect).

Population and Sample

Population:

In statistics, the population comprises all observations (data points) about the subject under study.

An example of a population is studying the voters in an election. In the 2019 Lok Sabha elections, nearly 900 million
voters were eligible to vote in 543 constituencies.

Sample:

In statistics, a sample is a subset of the population. It is a small portion of the total observed population.

An example of a sample is analyzing the first-time voters for an opinion poll.


Measures of Central Tendency

Measures of central tendency are the measures that are used to describe the distribution of data using a
single value. Mean, Median and Mode are the three measures of central tendency.

Mean:
The arithmetic mean is the average of all the data points.

If there are n number of observations and xi is the ith observation, then mean is:
Median:
Median is the middle value that divides the data into two equal parts once it sorts the data in ascending order.

If the total number of data points (n) is odd, the median is the value at position (n+1)/2.

When the total number of observations (n) is even, the median is the average value of observations at n/2 and
(n+2)/2 positions.

The median() function in Python can help you find the median value of a column. From the above data
frame, you can find the median salary as:
Mode:
The mode is the observation (value) that occurs most
frequently in the data set. There can be over one mode in a
dataset.

Given below are the heights of students (in cm) in a class:

155, 157, 160, 159, 162, 160, 161, 165, 160, 158

Mode = 160 cm.

The mode salary from the data frame can be calculated as:
Variance and Standard Deviation

Variance is used to measure the variability in the data from the mean.
Thank you…

You might also like