Forward chaining.

  1. It is also known as data driven inference technique.
  2. Forward chaining matches the set of conditions and infer results from these conditions. Basically, forward chaining starts from a new data and aims for any conclusion.
  3. It is bottom up reasoning.
  4. It is a breadth first search.
  5. It continues until no more rules can be applied or some cycle limit is met.
  6. For example: If it is cold then I will wear a sweater. Here “it is cold is the data” and “I will wear a sweater”is a decision. It was already known that it is cold that is why it was decided to wear a sweater, This process is forward chaining.
  7. It is mostly used in commercial applications i.e event driven systems are common example of forward chaining.
  8. It can create an infinite number of possible conclusions.

Code

#include<iostream.h>
#include<conio.h>
char database[4][10]={"Croaks","Eat Flies","Shrimps","Sings"};
char knowbase[4][10]={"Frog","Canary","Green","Yellow"};
int k=0,x=0;
void display();//display text
void main()
{
clrscr();
cout<<"*-----Forward--Chaning-----*";
display();
cout<<" \n";
if(x==1 || x== 2)
{
cout<<" Chance Of Frog ";
}
else if(x==3 || x==4)
{
cout<<" Chance of Canary ";
}
else
{
cout<<"\n-------In Valid Option Select --------";
}
if(x>=1 && x<=4)
{
cout<<"\n X is "<<database[x-1];
cout<<"\n Color Is 1.Green 2.Yellow";
cout<<"\n Select Option  ";
cin>>k;

if(k==1 && (x==1 || x==2))//frog0 and green1
cout<<" yes it is "<<knowbase[0]<<" And Color Is "<<knowbase[2];
else if(k==2 &&(x==3 || x==4))//canary1 and yellow3
cout<<" yes it is "<<knowbase[1]<<" And Color Is "<<knowbase[3];
else
{
cout<<"\n---InValid Knowledge Database";
}
}
getch();
}
void display()
{
cout<<"\n X is \n1.Croaks \n2.Eat Flies \n3.shrimps \n4.Sings ";
cout<<"\n Select One ";
cin>>x;
}

OUTPUT

Forward Chaining

Forward Chaining
Forward Chaining
(Visited 2,510 times, 1 visits today)
Share with Friends :
Written by: