CLIPS Presentacion
Transcript of CLIPS Presentacion
-
8/19/2019 CLIPS Presentacion
1/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Sistemas Expertos - CLIPS
Verónica E. Arriola-Rios
Inteligencia Articial
8 de septiembre de 2015
Verónica E. Arriola-Rios CLIPS
http://find/
-
8/19/2019 CLIPS Presentacion
2/23
-
8/19/2019 CLIPS Presentacion
3/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Conocimiento Procedimental
Una representación procedimental, es aquella en la que lainformación de control necesaria para utilizar el conocimiento seencuentra embebida en el propio conocimiento.
Verónica E. Arriola-Rios CLIPS
http://find/
-
8/19/2019 CLIPS Presentacion
4/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Componentes de CLIPS
1 Lista de hechos.2 Base de conocimento: reglas.3 Máquina de inferencias: controla la ejecución.
Verónica E. Arriola-Rios CLIPS
http://find/http://goback/
-
8/19/2019 CLIPS Presentacion
5/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Hechos
Los hechos están in tegrados por:El nombre de la relación
seguido de zero o más campos con nombre o rendijas y susvalores asociados (sin importar el orden).
( p er so n ( n am e J oh n Q . P ub li c )( a ge 2 3)(eye -co lor b lue )
(hai r- co lo r b lack) )
Verónica E. Arriola-Rios CLIPS
C i i P di l Si i E d d
http://find/
-
8/19/2019 CLIPS Presentacion
6/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Representación de los hechos
Es posible denir plantillas para los hechos añadibles a lamemoria.(deftemplate []*)
Por ejemplo:(deftemplate person “An example deftemplate”(multislot name) (slot age) (slot eye-color)(slot hair-color))
Los hechos pueden ser añadidos (assert ) o removidos(retract ) de la memoria. modify es una abreviatura queremueve y luego añade un hecho, pero con el valor de unarendija modicada.
Verónica E. Arriola-Rios CLIPS
C i i t P di t l Si t i E t t d d t
http://find/http://goback/
-
8/19/2019 CLIPS Presentacion
7/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Reglas
Si todos los patrones solicitados por la regla cazan con hechosen la memoria, la regla se activa y es agregada a una agenda ,la colección de reglas activadas.(defrule []* ; Left-Hand Side=>*) ; Right-Hand Side
El RHS contiene la lista de acciones a ejecutar cuando la reglasea disparada .
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
8/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Mundo de bloques
A DB EC F
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
9/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Mundo de bloques: estado inicial
(de f t emplate on- top-of( s lo t u pp er )( s lot lower ) )
(deffac ts in it ial - s ta te( bloc k A ) ( blo ck B )( bloc k C ) ( blo ck D )( bloc k E ) ( blo ck F )( on - t op - o f ( u p pe r n ot hi ng ) ( l o we r A ))( on - top - o f ( u pp er A ) ( l ow er B ))( on - top - o f ( u pp er B ) ( l ow er C ))( on - t op - o f ( u p pe r C ) ( l o we r f lo or ) )
( on - t op - o f ( u p pe r n ot hi ng ) ( l o we r D ))( on - top - o f ( u pp er D ) ( l ow er E ))( on - top - o f ( u pp er E ) ( l ow er F ))( on - t op - o f ( u p pe r F ) ( l o we r f lo or ) )( g oa l ( m ov e C ) ( on - top - o f E ))
)
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
10/23
Conocimiento Procedimental Sintaxis Estructuras de datos
Regla: move-directly
(de f rule move- d i rec tly? g oa l < - ( g oa l ( m ov e ? b lo ck 1 ) ( on - top - o f ? b lo ck 2 ))( b lo ck ? b l oc k1 )( b lo ck ? b l oc k2 )( on - t op - of ( u p pe r n ot hi ng ) ( l o we r ? b l oc k1 ) )? s ta ck -1 < - ( on - t op - of ( u p pe r ? b l oc k1 )
( lower ?b lock3) )? s ta ck -2 < - ( on - t op - of ( u p pe r n ot hi ng )
( lower ?b lock2) )=>( r e tr ac t ? g oa l ? s t ac k1 ? s t ac k2 )( a s se rt ( on - t op - of ( u pp er ? b l oc k1 )
( lower ?b lock2) )( on - t op - of ( u pp er n ot hi ng )
( lower ?b lock3) ) )( p ri nt ou t t ? b loc k1 " mo ved on top of " ? b loc k2 )
)
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
11/23
Regla: move-to-oor
(de f rule move- to - f loor? g oa l < - ( g oa l ( m ov e ? b lo ck 1 ) ( on - top - o f f lo or ) )( b lo ck ? b l oc k1 )( on - t op - of ( u p pe r n ot hi ng ) ( l o we r ? b l oc k1 ) )? s ta ck < - ( on - t op - o f ( u p pe r ? b l oc k1 )
( lower ?b lock2) )=>( r e tr ac t ? g oa l ? s ta ck )( a s se rt ( on - t op - of ( u pp er ? b l oc k1 )
( lower f loor ) )( on - t op - of ( u pp er n ot hi ng )
( lower ?b lock2) ) )( p ri nt ou t t ? b loc k1 " mo ved on top of floo r ")
)
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/http://goback/
-
8/19/2019 CLIPS Presentacion
12/23
Regla: clear-upper-block
(de f rule c lear -upper -b lock( g oa l ( m ov e ? b l oc k1 ) )( b lo ck ? b l oc k1 )( on - t op - of ( u p pe r ? b l oc k2 ) ( l o we r ? b l oc k1 ) )( b lo ck ? b l oc k2 )=>( a s se rt ( g oa l ( m ov e ? b l oc k2 ) ( on - t op - o f f lo or ) ) )
)
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
13/23
Regla: clear-lower-block
(de f rule c lear - lower -b lock( g oa l ( on - t op - o f ? b l oc k1 ) )( b lo ck ? b l oc k1 )( on - t op - of ( u p pe r ? b l oc k2 ) ( l o we r ? b l oc k1 ) )( b lo ck ? b l oc k2 )=>( a s se rt ( g oa l ( m ov e ? b l oc k2 ) ( on - t op - o f f lo or ) ) )
)
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
14/23
Ejecución
C LI PS > ( r un )
A moved on top of floor .B moved on top of floor .D moved on top of floor .C moved on top of E.
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
15/23
Aplicación de las reglas
En general, las reglas de una máquina de inferencias puedenser aplicadas:
Hacia adelante: de hechos a objetivos.Hacia atrás: desde los objetivos.
CLIPS utiliza únicamente encadenamiento hacia adelante.Cuando las precondiciones de una regla se satisfacen, la regladispara.
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://goforward/http://find/
-
8/19/2019 CLIPS Presentacion
16/23
Temas
1 Conocimiento ProcedimentalDeniciónCLIPS
2 Sintaxis
3 Estructuras de datos
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
17/23
Sintaxis
CLIPS es sensitivo al uso de mayúsculas y minúsculas.Las llamadas a funciones van entre paréntesis.Ej:
CLIPS > (+ 3 4) \ e n te rs ym bo l7C LI PS > ( e xi t ) \ e n t er s ym bo l
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
18/23
Comandos
CLIPS cuenta con varios comandos para seguir la evolución de lasinferencias:
(facts) Lista los hechos en la base de conocimientos.
(watch ) Donde los artículos a observar puedenser facts, rules, activations, statistics, compilations,focus y all .
(run []) Ejecuta el programa disparando las reglas en laagenda. Es posible jar el número máximo de reglasa disparar.
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
19/23
Campos
CLIPS tiene siete tipos primitivos:oatintegersymbolstringexternal addressinstance name
instance addressLos últimos tres se utilizan cuando el usuario dene funciones en Cpara extender el sistema.
Verónica E. Arriola-Rios CLIPS
http://find/http://goback/
-
8/19/2019 CLIPS Presentacion
20/23
Conocimiento Procedimental Sintaxis Estructuras de datos
-
8/19/2019 CLIPS Presentacion
21/23
Temas
1 Conocimiento ProcedimentalDeniciónCLIPS
2 Sintaxis
3 Estructuras de datos
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
22/23
Pilas
(de f ru le push- value? p ush - v a lu e < - ( p us h - v a lu e ? n am e ? v a lu e )
? s ta ck < - ( s ta ck ? n am e ? r est )=>( r e tr ac t ? p ush - v a lu e ? s ta ck )( a s se rt ( s ta ck ? v a lu e $ ? r es t ))( p ri nt ou t t " P us hi ng v al ue " ? v al ue c rl f ))
Verónica E. Arriola-Rios CLIPS
Conocimiento Procedimental Sintaxis Estructuras de datos
http://find/
-
8/19/2019 CLIPS Presentacion
23/23
Pilas (pop)
(de f ru le pop-va lue -va l id? pop - v a lu e < - ( pop - v a lu e ? n am e )? s ta ck < - ( s ta ck ? n am e ? v al ue $ ? re st )=>( r e tr ac t ? pop - v a lu e ? n am e ? s ta ck )
( a s se rt ( s ta ck ? n am e ? r es t ))( p ri nt ou t t " P op pi ng v al ue " ? v al ue c rl f ))
(de f ru le pop-va lue - inval id? pop - v a lu e < - ( pop - v a lu e ? n am e )( s t ac k ? n am e )
=>( r e tr ac t ? pop - v a lu e ? n am e )( p ri nt ou t t " P op pi ng f ro m e mp ty s ta ck " ? n am e cr lf ) )
Verónica E. Arriola-Rios CLIPS
http://find/