UNIT-II
Procedural Vs Declarative Knowledge;-
Procedural Knowledge:
Procedural Knowledge also known as Interpretive knowledge, is the type of knowledge in which it clarifies
how a particular thing can be accomplished.
It is not so popular because it is generally not used.
It emphasize how to do something to solve a given problem.
Let's see it with an example:
var a=[1, 2, 3, 4, 5];
var b=[];
for(var i=0;i<a.length;i++)
{
b.push(a[i]);
}
console.log(b);
Output is:
[1, 2, 3, 4, 5]
Declarative Knowledge:
Declarative Knowledge also known as Descriptive knowledge, is the type of knowledge which tells the
basic knowledge about something and it is more popular than Procedural Knowledge.
It emphasize what to do something to solve a given problem.
Let's see it with an example:
var a=[1, 2, 3, 4, 5];
var b=a.map(function(number)
{
return number*1});
console.log(b);
Output is:
[1, 2, 3, 4, 5]
In both example we can see that the output of a given problem is same because the only difference in that two
methods to achieve the output or solution of problem.
Difference the Procedural and Declarative Knowledge:
S.NO Procedural Knowledge Declarative Knowledge
1. It is also known as Interpretive knowledge. It is also known as Descriptive knowledge.
Procedural Knowledge means how a particular thing While Declarative Knowledge means basic
2.
can be accomplished. knowledge about something.
Procedural Knowledge is generally not used means it
3. Declarative Knowledge is more popular.
is not more popular.
4. Procedural Knowledge can't be easily communicate. Declarative Knowledge can be easily communicate.
Procedural Knowledge is generally process oriented in
5. Declarative Knowledge is data oriented in nature.
nature.
In Procedural Knowledge debugging and validation is In Declarative Knowledge debugging and validation
6.
not easy. is easy.
Procedural Knowledge is less effective in competitive Declarative Knowledge is more effective in
7.
programming. competitive programming.
LOGIC PROGRAMMING;-
Logic programming is a programming paradigm that utilizes formal logic to represent and
manipulate knowledge.
Instead of explicitly instructing the computer on how to perform a task (imperative programming),
logic programming focuses on describing what the desired outcome is.
This is achieved by expressing knowledge as logical statements (facts and rules) and using logical
reasoning to derive new information and solve problems.
Prolog is a well-known language based on this paradigm.
Key Concepts:
Facts:
Basic statements that are assumed to be true. For example, "parent(john, mary)."
Rules:
Logical statements that define relationships based on conditions. For example, "grandparent(X, Z) :-
parent(X, Y), parent(Y, Z)."
Queries:
Questions asked to the program to retrieve information or verify if a statement is true based on the facts
and rules. For example, "?- grandparent(john, X)."
How it works:
1. Knowledge Representation:
Facts and rules define the relationships and constraints within a specific domain.
2. Inference:
The logic programming system uses logical inference (reasoning) to derive new facts from the
existing ones and the rules.
3. Query Answering:
When a query is submitted, the system tries to find a sequence of logical inferences that can prove
the query true.
Advantages:
Declarative:
Focuses on what needs to be achieved rather than how to achieve it, leading to more concise and readable
code, particularly for complex problems
Knowledge-based:
Well-suited for representing and reasoning about knowledge, making it useful in areas like expert
systems, knowledge representation, and natural language processing
Flexibility:
The separation of knowledge and control logic allows for easier modification and adaptation of programs
Rapid prototyping:
The declarative nature allows for quick development of executable specifications
Example:
Code
parent(john,mary).
parent(mary,peter).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
In this example:
parent(john, mary). is a fact stating that John is the parent of Mary.
parent(mary, peter). is another fact.
grandparent(X, Z) :- parent(X, Y), parent(Y, Z). is a rule stating that X is the grandparent of Z if X
is a parent of Y, and Y is a parent of Z.
A query like ?- grandparent(john, peter). would be answered with true because the system can infer that
John is the grandparent of Peter based on the facts and the rule.
Forward And Backward Reasoning In Ai;-
In artificial intelligence, forward and backward reasoning are two fundamental approaches to
problem-solving and knowledge representation.
Forward reasoning ;-
It is a process in artificial intelligence that finds all the possible solutions of a problem based on
the initial data and facts.
Thus, the forward reasoning is a data-driven task as it begins with new data.
The main objective of the forward reasoning in AI is to find a conclusion that would follow.
It uses an opportunistic type of approach.
Backward reasoning
It is the reverse process of the forward reasoning in which a goal or hypothesis is selected and it is
analyzed to find the initial data, facts, and rules.
Therefore, the backward reasoning is a goal driven task as it begins with conclusions or goals that
are uncertain.
The main objective of the backward reasoning is to find the facts that support the conclusions.
Difference between Forward and Backward Reasoning in AI;-
S.No
Forward Reasoning Backward Reasoning
.
1. It is a data-driven task. It is a goal driven task.
2. It begins with new data. It begins with conclusions that are uncertain.
The objective is to find a conclusion that would The objective is to find the facts that support
3.
follow. the conclusions.
4. It uses an opportunistic type of approach. It uses a conservative type of approach.
5. It flows from incipient to the consequence. It flows from consequence to the incipient.
Backward reasoning begins with some goal
6. Forward reasoning begins with the initial facts.
(hypothesis).
7. Forward reasoning tests all the rules. Backward reasons tests some rules.
8. Forward reasoning is a bottom-up approach. Backward reasoning is a top-down approach.
Forward reasoning can produce an infinite Backward reasoning produces a finite
9.
number of conclusion. number of conclusions.
In the forward reasoning, all the data is In the backward reasoning, the data is
10.
available. acquired on demand.
Forward reasoning has a small number of initial Backward reasoning has a smaller number of
11.
states but a large number of conclusions. goals and a larger number of rules.
In forward reasoning, the goal formation is In backward reasoning, it is easy to form a
12.
difficult. goal.
Backward reasoning work in backward
Forward reasoning works in forward direction to
13. direction to find the facts that justify the
find all the possible conclusions from facts.
goal.
Forward reason is suitable to answer the
Backward reasoning is suitable for diagnosis
14. problems such as planning, control, monitoring,
like problems.
etc.
Conclusion;-
The most significant difference between the two approaches is that forward reasoning is a data-
driven task, while backward reasoning is a goal-driven task.
Matching in AI;-
AI matching refers to the use of artificial intelligence, particularly machine learning, to identify
and link related data points or objects, often based on similarity or shared characteristics.
This can be applied to various domains, including candidate selection, record linkage, and even
pattern recognition.
The core idea is to automate and improve matching processes that would otherwise be time-
consuming or prone to human error.
Key aspects of AI matching:
Automated Screening:
AI matching can automate the initial screening of candidates, identifying those who best match job
requirements, based on skills, experience, and other criteria.
Record Linkage:
In data management, AI can link records from different sources that refer to the same entity, such as
customer profiles or product information, even if the data is inconsistent or incomplete.
Fuzzy Matching:
AI can handle "fuzzy" or approximate matches, recognizing similarities even when data isn't perfectly
identical, such as variations in names or addresses.
Pattern Recognition:
AI matching can identify patterns and relationships in data, which can be useful for fraud detection,
anomaly detection, and other applications.
Learning and Adaptation:
Many AI matching systems learn from user feedback and data patterns to improve their accuracy and
effectiveness over time.
Transparency and Explainability:
Some AI matching systems are designed to provide transparent explanations for why a particular match
was made, which can be important for building trust and understanding.
Examples:
Recruitment: Matching candidates to job postings based on skills, experience, and other
factors.
Data deduplication: Identifying and merging duplicate records in a database.
E-commerce: Matching products to customer preferences or recommendations.
Fraud detection: Identifying potentially fraudulent transactions based on patterns of
behavior.
Benefits of AI matching:
Increased Efficiency:
Automation can significantly reduce the time and resources required for matching tasks.
Improved Accuracy:
AI can identify subtle patterns and relationships that might be missed by humans.
Reduced Bias:
AI matching can help to reduce human bias in decision-making processes.
Enhanced Insights:
AI can reveal hidden connections and patterns in data that can lead to valuable insights.
Control Knowledge in AI:-
Control knowledge in AI refers to the information and strategies used to guide the AI system's
reasoning and decision-making processes, ensuring efficient and effective problem-solving.
It dictates how the AI should evaluate facts and rules, determine the order of operations, and
select which actions to take to achieve a desired outcome.
Essentially, it's the "how to" part of AI, complementing the "what" (knowledge) and "why"
(reasoning).
Key aspects of control knowledge:
Meta-reasoning:
Control knowledge allows the AI to reason about its own reasoning process, enabling it to make decisions
about how to proceed in a given situation.
Search control:
It helps in navigating the search space during problem-solving, guiding the AI to explore promising paths
and avoid unproductive ones.
Rule selection:
Control knowledge determines which rules or actions are most relevant and should be applied at a
specific stage of the process.
Evaluation and prioritization:
It defines criteria for evaluating the potential outcomes of different actions and prioritizing them based on
their likelihood of leading to the desired goal.
Integration with other knowledge:
Control knowledge is not isolated; it interacts with other forms of knowledge, such as factual knowledge
and procedural knowledge, to enable intelligent behavior.
Examples of control knowledge in action:
Forward chaining:
In forward chaining, the AI evaluates rules based on the current state and applies those that
are relevant, guided by control knowledge about which rules are most likely to lead to the
goal.
Backward chaining:
Similarly, in backward chaining, control knowledge helps determine which subgoals need
to be achieved first to reach the overall goal.
Planning:
Control knowledge is crucial for planning, enabling the AI to sequence actions, optimize
resource allocation, and adapt to changing environments.
Benefits of using control knowledge:
Improved efficiency:
By guiding the search process and prioritizing actions, control knowledge can significantly
reduce the time and resources required to solve a problem.
Enhanced performance:
Effective control knowledge can lead to more accurate and reliable solutions by ensuring
that the AI focuses on the most relevant information and actions.
Adaptability:
Control knowledge allows AI systems to adapt to changing environments and unexpected
situations by adjusting their reasoning strategies.
Explainability:
In some cases, control knowledge can be used to explain the reasoning behind an AI's
decisions, making them more transparent and understandable.