Prolog has a helpful and clean syntax [1] (at least when you're used to :P) and it's easy to define new operators syntax in SWI [2]. Such feature improves the readability of the knowledge base.
To make an abductive reasoning we will need at least the logic operators 'and','or' and 'implies' to represent knowledge and chain it.
Our simple language will have the following syntax:
- known X. - Says that the sentence X must be true;
- X <- Y - X is caused by Y;
- X & Y - Is true if X and Y are true;
- X v Y - Is true if X or Y are true ('|' is already used by Prolog);
- assumable X - X can be assumed to prove something;
- askable X - X can be asked to the user;
Note that I'm not using the negation, because some dangerous particularities of Prolog negation as failure.
It's interesting to note the similarity if we represented with the defaul prefixed notation of Prolog predicades:
- known(X)
- <-(X,Y)
- &(X,Y)
- v(X,Y)
- assumable(X)
- askable(X)
Defining opertors increases the readabilty of the knowledge representation significantly. To redefine operators we will use the SWI predicate op/3 [2]. We can only run this predicate like:
:- op(910, xfy, &).
The op predicate has three fields op(+Precedence, +Type, :Name). The first one says the precendence of the operator (a number between 0 and 1200). The second is how the functor will be placed within it's "children nodes", for example: xfy let the functor between the arguments while xf let the functor after it's argument (remembering that you can only create unary or binary operators). For our representation language we will have:
:- discontiguous( known/1 ). % The discontiguous predicate tells Prolog :- discontiguous( assumable/1 ). % that the given predicate can be declared :- discontiguous( askable/1 ). % unsorted. :- op(910, xfy, & ). % a higher priority with an infix notation :- op(920, xfy, v ). % infix notation and lower priority than & :- op(930, xfy, <- ). % infix notation :- op(940, fx, known ). % prefixed notation and lowest priority :- op(940, fx, assumable ). % prefixed notation and lowest priority :- op(940, fx, askable ). % prefixed notation and lowest priority
Now let's model the car problems knowledge into our language (remember that Upper names are variables):
% % DiagnostiCar - Knowledge Base % % Observe that implication is seen as the real sense of consequence <- cause. known problem(crank_case_damaged) <- crank_case_damaged. known problem(hydraulic_res_damaged) <- hydraulic_res_damaged. known problem(brakes_res_damaged) <- brakes_res_damaged. known problem(old_engine_oil) <- old_engine_oil & leak_color(black). known leak(engine_oil) <- crank_case_damaged. known leak(hydraulic_oil) <- hydraulic_res_damaged. known leak(brakes_oil) <- brakes_res_damaged. % Implications in false can be seen as constraints. known oil(Oil) <- exists_leak(true) & leak(Oil). known false <- oil(brakes_oil) & leak_color(Color) & Color \= green. known false <- oil(engine_oil) & leak_color(Color) & Color \= brown & Color \= black. known false <- oil(hydraulic_oil) & leak_color(Color) & Color \= red. % The assumable predicate asserts what will be can be suposed assumable crank_case_damaged. assumable hydraulic_res_damaged. % to prove something e else. assumable brakes_res_damaged. assumable old_engine_oil. askable leak_color(Color). % Askable predicate asserts which information will be asked for the user. askable exists_leak(TrueOrFalse). % The argument of the predicate will be unified with the answer. known goal(X) <- problem(X). % The goal predicate is what we want to prove with the expert system.
That's all for now. On the next post I will explain the question and answer interface using the dynamic Prolog predicates.
[1] Prolog Syntax
Welcome to Wiztech Automation - Embedded System Training in Chennai. We have knowledgeable Team for Embedded Courses handling and we also are after Job Placements offer provide once your Successful Completion of Course. We are Providing on Microcontrollers such as 8051, PIC, AVR, ARM7, ARM9, ARM11 and RTOS. Free Accommodation, Individual Focus, Best Lab facilities, 100% Practical Training and Job opportunities.
ReplyDelete✔ Embedded System Training in chennai
✔ Embedded System Training Institute in chennai
✔ Embedded Training in chennai
✔ Embedded Course in chennai
✔ Best Embedded System Training in chennai
✔ Best Embedded System Training Institute in chennai
✔ Best Embedded System Training Institutes in chennai
✔ Embedded Training Institute in chennai
✔ Embedded System Course in chennai
✔ Best Embedded System Training in chennai
WIZTECH Automation, Anna Nagar, Chennai, has earned reputation offering the best automation training in Chennai in the field of industrial automation. Flexible timings, hands-on-experience, 100% practical. The candidates are given enhanced job oriented practical training in all major brands of PLCs (AB, Keyence, ABB, GE-FANUC, OMRON, DELTA, SIEMENS, MITSUBISHI, SCHNEIDER, and MESSUNG)
ReplyDeletePLC training in chennai
Automation training in chennai
Best plc training in chennai
PLC SCADA training in chennai
Process automation training in chennai
Final year eee projects in chennai
VLSI training in chennai
Best B.Tech College in Noida
ReplyDeleteBig Data and Hadoop is an ecosystem of open source components that fundamentally changes the way enterprises store, process, and analyze data.
ReplyDeletepython training in bangalore
aws training in bangalore
artificial intelligence training in bangalore
data science training in bangalore
machine learning training in bangalore
hadoop training in bangalore
devops training in bangalore
corporate training companies
ReplyDeletecorporate training companies in mumbai
corporate training companies in pune
corporate training companies in delhi
corporate training companies in chennai
corporate training companies in hyderabad
corporate training companies in bangalore
Gaining Python certifications will validate your skills and advance your career.
ReplyDeletepython certification
Amazing content.
ReplyDeleteData Mining Service Providers in Bangalore
Thanks for sharingData Mining software service providers
ReplyDeletepython training in bangalore | python online taining
ReplyDeleteaws training in bangalore | aws online training
artificial intelligence training in bangalore | artificial intelligence online training
machine learning training in bangalore | machine learning online training
data science training in bangalore | data science online training
This professional hacker is absolutely reliable and I strongly recommend him for any type of hack you require. I know this because I have hired him severally for various hacks and he has never disappointed me nor any of my friends who have hired him too, he can help you with any of the following hacks:
ReplyDelete-Phone hacks (remotely)
-Credit repair
-Bitcoin recovery (any cryptocurrency)
-Make money from home (USA only)
-Social media hacks
-Website hacks
-Erase criminal records (USA & Canada only)
-Grade change
-funds recovery
Email: onlineghosthacker247@ gmail .com
Studyprovider has experts team are giving the homework help, assignment help, report, thesis, research writing services and chemical engineering assignment help available 24/7 seven days a week contact now.
ReplyDelete