Intro to CLIPSPaula MatuszekCSC 8750, Fall, 2004.ppt
《Intro to CLIPSPaula MatuszekCSC 8750, Fall, 2004.ppt》由会员分享,可在线阅读,更多相关《Intro to CLIPSPaula MatuszekCSC 8750, Fall, 2004.ppt(62页珍藏版)》请在麦多课文档分享上搜索。
1、10/9/2018,Expert Systems, Paula Matuszek,1,Intro to CLIPS Paula Matuszek CSC 8750, Fall, 2004,Based on presentation from COMP474/6741 Expert Systems Update: January 20, 2002 Concordia University A. Andreevskaia and S. Mokhiv www.cs.concordia.ca/comp474/tutorial/clips-intro.ppt,Expert Systems, Paula
2、Matuszek,2,10/9/2018,CLIPS History,CLIPS = C Language Integrated Production System Developed at NASAs Johnson Space Center in the mid-1980-s C was used as implementation language (because of restricted availability of LISP compilers and problems of integration LISP-code with non-LISP applications) I
3、nitial version: a production rule interpreter. Now: COOL = CLIPS Object-Oriented Language Also JESS: Java Expert Systems Shell,Expert Systems, Paula Matuszek,3,10/9/2018,Where does it fit?,Classical Rule-Based Expert Systems CLIPS as a Rule-Based Language CLIPS Components Forward Chaining (CLIPS) vs
4、. Backward Chaining (e.g. MYCIN and derivatives),Expert Systems, Paula Matuszek,4,10/9/2018,Why do we study CLIPS?,Advantages of CLIPS include: A top-level interpreter Production rule interpreter Runs on many platforms (portability) like different flavors of UNIX, Linux, Windows, MacOS A public-doma
5、in well-documented software Fast Easy to embed in other applications Easy to get started,Expert Systems, Paula Matuszek,5,10/9/2018,Components of a Rule-Based Expert System,Knowledge Base (RULES),Inference Engine,Agenda,Working Memory (FACTS),UI,Explanation Facility,Knowledge Acquisition Facility,Ex
6、pert Systems, Paula Matuszek,6,10/9/2018,Versions of CLIPS,CLIPS is written in C = CLIPS is portable = there are different versions that run on different platforms: mac, unix, windows. From CD you can get version for Windows Latest version 6.20 can be downloaded from the CLIPS web site.,Expert Syste
7、ms, Paula Matuszek,7,10/9/2018,Starting CLIPS,1. To start text-based CLIPS interpreter under UNIX you type clips and CLIPS prompt will appear. You can try simple CLIPS commands. Remember - like LISP CLIPS requires all statements to be in ( ); otherwise, it will read them as simple string and just ec
8、ho them. To exit CLIPS interpreter type (exit).,Expert Systems, Paula Matuszek,8,10/9/2018,Summary of Basic CLIPS Commands,(exit) to exit from CLIPS (clear) to clear the environment from facts, rules, and other active definitions (reset) to set the fact base to its initial state (clears existing fac
9、ts; sets (initial-fact), and all (deffacts) constructs in the program). Perform (reset) before each program run! (run) executes a program currently loaded into the CLIPS interpreter against currently defined rule- and fact-bases.,Expert Systems, Paula Matuszek,9,10/9/2018,More Basic CLIPS Commands,(
10、load “filename.clp”) to load a CLIPS program into the interpreter from the file named filename.clp . This also does syntax check and makes constructs in the file defined. In some cases you may omit quotes in the name. (facts) to display a list of currently active facts in the fact base. (rules) to d
11、isplay a set of rules currently in the rule base.,Expert Systems, Paula Matuszek,10,10/9/2018,Comments in CLIPS,Program comments begin with a semicolon “;”. Everything after on the same line until the end of line is ignored. ; This is an inline comment example Construct comments are used as a part o
12、f the CLIPS constructs (e.g. deftemplate, defrule, etc) and follows the constructs name and enclosed in quotations. (defrule my-rule “my comment” (initial-fact) = (printout t “Hello” crlf) ),Expert Systems, Paula Matuszek,11,10/9/2018,Few Simple Clips Commands,To assert a fact:(assert (first-fact as
13、serted) To define a rule:(defrule first_rule (first-fact asserted)=(assert (second-fact asserted),Expert Systems, Paula Matuszek,12,10/9/2018,“Hello World” in CLIPS,(defrule start(initial-fact) =(printout t “Hello, world!” crlf),Expert Systems, Paula Matuszek,13,10/9/2018,To Make It Run,Type the cod
14、e in a file, save it (e.g. hello-world.clp) Start CLIPS (type clips or xclips) Do: File - Load (in XCLIPS) or type (load hello-world.clp) When the file is loaded CLIPS will display:(load hello-world.clp)defining defrule start +jTRUE,Expert Systems, Paula Matuszek,14,10/9/2018,To Make It Run,Type (re
15、set) Type (run)Tip: You can also use the menu To exit CLIPS use the menu, Q or (exit),Expert Systems, Paula Matuszek,15,10/9/2018,Fields,There are seven data types (types of tokens) called fields in CLIPS. float: +- * .* e|E+|-* integer: +|- * symbol: * string: “* “ (e.g. “John”, “848-3000”) externa
16、l address instance name instance address,Expert Systems, Paula Matuszek,16,10/9/2018,Word,a word CANNOT start with these: | ,Expert Systems, Paula Matuszek,17,10/9/2018,Valid Expressions,Examples of valid words fire emergency-fire activate_sprinkler_systemshut-down-electrical-junction-387!?#$* CLIPS
17、 is case-sensitive So fire FIRE Fire are all different,Expert Systems, Paula Matuszek,18,10/9/2018,Valid Expressions,Examples of valid strings “Activate the sprinkler system.” “Shut down electrical junction 387.” “!?#$” “-;( ) +-” Spaces act as delimiters to separate fields These are different strin
18、gs “fire” “fire “ “ fire” “ fire “ but would be the same with no quotes Valid numbers 1 1.5 .7 +3 -1 65 3.5e10,Expert Systems, Paula Matuszek,19,10/9/2018,Facts,Fact is a chunk of information consisting of relation name, (optional) slots and slot values. Example: (person (name “John”) In CLIPS facts
19、 are frame structures often defined using the (deftemplate) construct.,Expert Systems, Paula Matuszek,20,10/9/2018,(deftemplate),(deftemplate * )is:(slot ) (field ) (multislot ),Expert Systems, Paula Matuszek,21,10/9/2018,Valid Facts,Examples of valid facts(single-field)(two fields)(speed 38 mph)(co
20、st 78 dollars 23 cents)(name “John Doe”),Expert Systems, Paula Matuszek,22,10/9/2018,(deftemplate) Example,(deftemplate person “an example template”(multislot name)(slot age)(slot eye-color)(slot hair-color) CLIPS defining deftemplate: person TRUE,Expert Systems, Paula Matuszek,23,10/9/2018,Facts,De
21、ftemplate can also be implicit = ordered facts: (numbers 1 2 3) To add facts: (assert ) (you can add more than one fact with the same (assert) command) To remove facts: (retract *) To list facts: (facts) will give facts identifiers like f-0 (not sequential),Expert Systems, Paula Matuszek,24,10/9/201
22、8,Facts Example,CLIPS (deftemplate course “electives”(slot number) CLIPS (assert (course (number comp674)(course (number comp672)CLIPS (facts) f-0 (course (number comp674) f-1 (course (number comp672) For a total of 2 facts CLIPS (retract 1) CLIPS (facts) f-0 (course (number comp674) For a total of
23、1 fact,Expert Systems, Paula Matuszek,25,10/9/2018,Modifying Facts,To modify a fact: (modify *)is ( ) Example: CLIPS (modify 0 (number comp675)CLIPS (facts) f-2 (course (number comp675) for a total of 1 fact,Expert Systems, Paula Matuszek,26,10/9/2018,Duplicating Facts,To create a duplicate of a fac
24、t: Example (continued) CLIPS (duplicate 2 (number comp775)CLIPS (facts) f-2 (course (number comp675) f-3 (course (number comp775) For a total of 2 facts Note: (duplicate) modifies a fact without deleting (retracting) the original, whereas (modify) does.,Expert Systems, Paula Matuszek,27,10/9/2018,As
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- INTROTOCLIPSPAULAMATUSZEKCSC8750 FALL 2004 PPT

链接地址:http://www.mydoc123.com/p-376607.html